class_docstr: DiNTS topology search space of neural architectures.
  
  Examples:
  
  .. code-block:: python
  
      from monai.networks.nets.dints import TopologySearch
  
      topology_search_space = TopologySearch(
          channel_mul=0.5, num_blocks=8, num_depths=4, use_downsample=True, spatial_dims=3)
      topology_search_space.get_ram_cost_usage(in_size=(2, 16, 80, 80, 80), full=True)
      multi_res_images = [
          torch.randn(2, 16, 80, 80, 80),
          torch.randn(2, 32, 40, 40, 40),
          torch.randn(2, 64, 20, 20, 20),
          torch.randn(2, 128, 10, 10, 10)]
      prediction = topology_search_space(image)
      for x in prediction: print(x.shape)
      # torch.Size([2, 16, 80, 80, 80])
      # torch.Size([2, 32, 40, 40, 40])
      # torch.Size([2, 64, 20, 20, 20])
      # torch.Size([2, 128, 10, 10, 10])
  
  Class method overview:
  
      - ``get_prob_a()``: convert learnable architecture weights to path activation probabilities.
      - ``get_ram_cost_usage()``: get estimated ram cost.
      - ``get_topology_entropy()``: get topology entropy loss in searching stage.
      - ``decode()``: get final binarized architecture code.
      - ``gen_mtx()``: generate variables needed for topology search.
  
  Predefined variables:
      - `tidx`: index used to convert path activation matrix T = (depth,depth) in transfer_mtx to
        path activation arch_code (1,3*depth-2), for depth = 4, tidx = [0, 1, 4, 5, 6, 9, 10, 11, 14, 15],
        A tidx (10 binary values) represents the path activation.
      - `transfer_mtx`: feasible path activation matrix (denoted as T) given a node activation pattern.
        It is used to convert path activation pattern (1, paths) to node activation (1, nodes)
      - `node_act_list`: all node activation [2^num_depths-1, depth]. For depth = 4, there are 15 node activation
        patterns, each of length 4. For example, [1,1,0,0] means nodes 0, 1 are activated (with input paths).
      - `all_connect`: All possible path activations. For depth = 4,
        all_connection has 1024 vectors of length 10 (10 paths).
        The return value will exclude path activation of all 0.
class_docstr_tok: ["DiNTS","topology","search","space","of","neural","architectures",".","Examples",":","..","code-block",":",":","python","from","monai.networks.nets.dints","import","TopologySearch","topology_search_space","=","TopologySearch","(","channel_mul=0.5",",","num_blocks=8",",","num_depths=4",",","use_downsample=True",",","spatial_dims=3",")","topology_search_space.get_ram_cost_usage","(","in_size=","(","2",",","16",",","80",",","80",",","80",")",",","full=True",")","multi_res_images","=","[","torch.randn","(","2",",","16",",","80",",","80",",","80",")",",","torch.randn","(","2",",","32",",","40",",","40",",","40",")",",","torch.randn","(","2",",","64",",","20",",","20",",","20",")",",","torch.randn","(","2",",","128",",","10",",","10",",","10",")","]","prediction","=","topology_search_space","(","image",")","for","x","in","prediction",":","print","(","x.shape",")","#","torch.Size","(","[","2",",","16",",","80",",","80",",","80","]",")","#","torch.Size","(","[","2",",","32",",","40",",","40",",","40","]",")","#","torch.Size","(","[","2",",","64",",","20",",","20",",","20","]",")","#","torch.Size","(","[","2",",","128",",","10",",","10",",","10","]",")","Class","method","overview",":","-","``","get_prob_a","(",")","``",":","convert","learnable","architecture","weights","to","path","activation","probabilities",".","-","``","get_ram_cost_usage","(",")","``",":","get","estimated","ram","cost",".","-","``","get_topology_entropy","(",")","``",":","get","topology","entropy","loss","in","searching","stage",".","-","``","decode","(",")","``",":","get","final","binarized","architecture","code",".","-","``","gen_mtx","(",")","``",":","generate","variables","needed","for","topology","search",".","Predefined","variables",":","-","`","tidx","`",":","index","used","to","convert","path","activation","matrix","T","=","(","depth",",","depth",")","in","transfer_mtx","to","path","activation","arch_code","(","1,3","*","depth-2",")",",","for","depth","=","4",",","tidx","=","[","0",",","1",",","4",",","5",",","6",",","9",",","10",",","11",",","14",",","15","]",",","A","tidx","(","10","binary","values",")","represents","the","path","activation",".","-","`","transfer_mtx","`",":","feasible","path","activation","matrix","(","denoted","as","T",")","given","a","node","activation","pattern",".","It","is","used","to","convert","path","activation","pattern","(","1",",","paths",")","to","node","activation","(","1",",","nodes",")","-","`","node_act_list","`",":","all","node","activation","[","2^num_depths-1",",","depth","]",".","For","depth","=","4",",","there","are","15","node","activation","patterns",",","each","of","length","4",".","For","example",",","[","1,1,0,0","]","means","nodes","0",",","1","are","activated","(","with","input","paths",")",".","-","`","all_connect","`",":","All","possible","path","activations",".","For","depth","=","4",",","all_connection","has","1024","vectors","of","length","10","(","10","paths",")",".","The","return","value","will","exclude","path","activation","of","all","0","."]
docstr: Get final path and child model probabilities from architecture weights `log_alpha_a`.
  This is used in forward pass, getting training loss, and final decoding.
  
  Args:
      child: return child probability (used in decoding)
  Return:
      arch_code_prob_a: the path activation probability of size:
          `[number of blocks, number of paths in each block]`.
          For 12 blocks, 4 depths search space, the size is [12,10]
      probs_a: The probability of all child models (size 1023x10). Each child model is a path activation pattern
           (1D vector of length 10 for 10 paths). In total 1023 child models (2^10 -1)
docstr_tok: ["Get","final","path","and","child","model","probabilities","from","architecture","weights","`","log_alpha_a","`",".","This","is","used","in","forward","pass",",","getting","training","loss",",","and","final","decoding",".","Args",":","child",":","return","child","probability","(","used","in","decoding",")","Return",":","arch_code_prob_a",":","the","path","activation","probability","of","size",":","`","[","number","of","blocks",",","number","of","paths","in","each","block","]","`",".","For","12","blocks",",","4","depths","search","space",",","the","size","is","[","12,10","]","probs_a",":","The","probability","of","all","child","models","(","size","1023x10",")",".","Each","child","model","is","a","path","activation","pattern","(","1D","vector","of","length","10","for","10","paths",")",".","In","total","1023","child","models","(","2^10","-1",")"]
code: def get_prob_a(self, child: bool = False):
      """
      Get final path and child model probabilities from architecture weights `log_alpha_a`.
      This is used in forward pass, getting training loss, and final decoding.
  
      Args:
          child: return child probability (used in decoding)
      Return:
          arch_code_prob_a: the path activation probability of size:
              `[number of blocks, number of paths in each block]`.
              For 12 blocks, 4 depths search space, the size is [12,10]
          probs_a: The probability of all child models (size 1023x10). Each child model is a path activation pattern
               (1D vector of length 10 for 10 paths). In total 1023 child models (2^10 -1)
      """
      _arch_code_prob_a = torch.sigmoid(self.log_alpha_a)
      # remove the case where all path are zero, and re-normalize.
      norm = 1 - (1 - _arch_code_prob_a).prod(-1)
      arch_code_prob_a = _arch_code_prob_a / norm.unsqueeze(1)
      if child:
          path_activation = torch.from_numpy(self.child_list).to(
              self.device
          )
          probs_a = [
              (
                  path_activation * _arch_code_prob_a[blk_idx]
                  + (1 - path_activation)
                  * (1 - _arch_code_prob_a[blk_idx])
              ).prod(-1)
              / norm[blk_idx]
              for blk_idx in range(self.num_blocks)
          ]
          probs_a = torch.stack(probs_a)  # type: ignore
          return probs_a, arch_code_prob_a
      return None, arch_code_prob_a
  
imports: from __future__ import annotations
  import datetime
  import warnings
  from typing import Optional
  import numpy
  import torch
  import torch.nn
  import torch.nn.functional
  from monai.networks.blocks.dints_block import ActiConvNormBlock, FactorizedIncreaseBlock, FactorizedReduceBlock, P3DActiConvNormBlock
  from monai.networks.layers.factories import Conv
  from monai.networks.layers.utils import get_act_layer, get_norm_layer
  from monai.utils import optional_import
label_desc: Use image node_id 4 for calling the TopologySearch obj's underlying member method code with example usage: obj.get_prob_a(child) and returns: None,  arch_code_prob_a, probs_a,  arch_code_prob_a