class_docstr: Reimplementation of DiNTS based on
  "DiNTS: Differentiable Neural Network Topology Search for 3D Medical Image Segmentation
  <https://arxiv.org/abs/2103.15954>".
  
  The model contains a pre-defined multi-resolution stem block (defined in this class) and a
  DiNTS space (defined in :py:class:`monai.networks.nets.TopologyInstance` and
  :py:class:`monai.networks.nets.TopologySearch`).
  
  The stem block is for: 1) input downsample and 2) output upsample to original size.
  The model downsamples the input image by 2 (if ``use_downsample=True``).
  The downsampled image is downsampled by [1, 2, 4, 8] times (``num_depths=4``) and used as input to the
  DiNTS search space (``TopologySearch``) or the DiNTS instance (``TopologyInstance``).
  
      - ``TopologyInstance`` is the final searched model. The initialization requires the searched architecture codes.
      - ``TopologySearch`` is a multi-path topology and cell operation search space.
        The architecture codes will be initialized as one.
      - ``TopologyConstruction`` is the parent class which constructs the instance and search space.
  
  To meet the requirements of the structure, the input size for each spatial dimension should be:
  divisible by 2 ** (num_depths + 1).
  
  Args:
      dints_space: DiNTS search space. The value should be instance of `TopologyInstance` or `TopologySearch`.
      in_channels: number of input image channels.
      num_classes: number of output segmentation classes.
      act_name: activation name, default to 'RELU'.
      norm_name: normalization used in convolution blocks. Default to `InstanceNorm`.
      spatial_dims: spatial 2D or 3D inputs.
      use_downsample: use downsample in the stem.
          If ``False``, the search space will be in resolution [1, 1/2, 1/4, 1/8],
          if ``True``, the search space will be in resolution [1/2, 1/4, 1/8, 1/16].
      node_a: node activation numpy matrix. Its shape is `(num_depths, num_blocks + 1)`.
          +1 for multi-resolution inputs.
          In model searching stage, ``node_a`` can be None. In deployment stage, ``node_a`` cannot be None.
class_docstr_tok: ["Reimplementation","of","DiNTS","based","on","''","DiNTS",":","Differentiable","Neural","Network","Topology","Search","for","3D","Medical","Image","Segmentation","<","https",":","\/\/arxiv.org\/abs\/2103.15954",">","''",".","The","model","contains","a","pre-defined","multi-resolution","stem","block","(","defined","in","this","class",")","and","a","DiNTS","space","(","defined","in",":","py",":","class",":","`","monai.networks.nets.TopologyInstance","`","and",":","py",":","class",":","`","monai.networks.nets.TopologySearch","`",")",".","The","stem","block","is","for",":","1",")","input","downsample","and","2",")","output","upsample","to","original","size",".","The","model","downsamples","the","input","image","by","2","(","if","``","use_downsample=True","``",")",".","The","downsampled","image","is","downsampled","by","[","1",",","2",",","4",",","8","]","times","(","``","num_depths=4","``",")","and","used","as","input","to","the","DiNTS","search","space","(","``","TopologySearch","``",")","or","the","DiNTS","instance","(","``","TopologyInstance","``",")",".","-","``","TopologyInstance","``","is","the","final","searched","model",".","The","initialization","requires","the","searched","architecture","codes",".","-","``","TopologySearch","``","is","a","multi-path","topology","and","cell","operation","search","space",".","The","architecture","codes","will","be","initialized","as","one",".","-","``","TopologyConstruction","``","is","the","parent","class","which","constructs","the","instance","and","search","space",".","To","meet","the","requirements","of","the","structure",",","the","input","size","for","each","spatial","dimension","should","be",":","divisible","by","2","*","*","(","num_depths","+","1",")",".","Args",":","dints_space",":","DiNTS","search","space",".","The","value","should","be","instance","of","`","TopologyInstance","`","or","`","TopologySearch","`",".","in_channels",":","number","of","input","image","channels",".","num_classes",":","number","of","output","segmentation","classes",".","act_name",":","activation","name",",","default","to","'RELU","'",".","norm_name",":","normalization","used","in","convolution","blocks",".","Default","to","`","InstanceNorm","`",".","spatial_dims",":","spatial","2D","or","3D","inputs",".","use_downsample",":","use","downsample","in","the","stem",".","If","``","False","``",",","the","search","space","will","be","in","resolution","[","1",",","1\/2",",","1\/4",",","1\/8","]",",","if","``","True","``",",","the","search","space","will","be","in","resolution","[","1\/2",",","1\/4",",","1\/8",",","1\/16","]",".","node_a",":","node","activation","numpy","matrix",".","Its","shape","is","`","(","num_depths",",","num_blocks","+","1",")","`",".","+1","for","multi-resolution","inputs",".","In","model","searching","stage",",","``","node_a","``","can","be","None",".","In","deployment","stage",",","``","node_a","``","can","not","be","None","."]
docstr: Prediction based on dynamic arch_code.
  
  Args:
      x: input tensor.
docstr_tok: ["Prediction","based","on","dynamic","arch_code",".","Args",":","x",":","input","tensor","."]
code: def forward(self, x: torch.Tensor):
      """
      Prediction based on dynamic arch_code.
  
      Args:
          x: input tensor.
      """
      inputs = []
      for d in range(self.num_depths):
          # allow multi-resolution input
          _mod_w: StemInterface = self.stem_down[str(d)]
          x_out = _mod_w.forward(x)
          if self.node_a[0][d]:
              inputs.append(x_out)
          else:
              inputs.append(torch.zeros_like(x_out))
  
      outputs = self.dints_space(inputs)
  
      blk_idx = self.num_blocks - 1
      start = False
      _temp: torch.Tensor = torch.empty(0)
      for res_idx in range(self.num_depths - 1, -1, -1):
          _mod_up: StemInterface = self.stem_up[str(res_idx)]
          if start:
              _temp = _mod_up.forward(outputs[res_idx] + _temp)
          elif self.node_a[blk_idx + 1][res_idx]:
              start = True
              _temp = _mod_up.forward(outputs[res_idx])
      prediction = self.stem_finals(_temp)
      return prediction
  
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 3 for calling the DiNTS obj's underlying member method code with example usage: obj.forward(x) and returns: prediction