class_docstr: Build Trunk Blocks
      
docstr: Build the blocks
  Args:
      in_chs: Number of input-channels passed to first block
      model_block_args: A list of lists, outer list defines stages, inner
          list contains strings defining block configuration(s)
  Return:
       List of block stacks (each stack wrapped in nn.Sequential)
docstr_tok: ["Build","the","blocks","Args",":","in_chs",":","Number","of","input-channels","passed","to","first","block","model_block_args",":","A","list","of","lists",",","outer","list","defines","stages",",","inner","list","contains","strings","defining","block","configuration","(","s",")","Return",":","List","of","block","stacks","(","each","stack","wrapped","in","nn.Sequential",")"]
code: def __call__(self, in_chs, model_block_args):
      """Build the blocks
      Args:
          in_chs: Number of input-channels passed to first block
          model_block_args: A list of lists, outer list defines stages, inner
              list contains strings defining block configuration(s)
      Return:
           List of block stacks (each stack wrapped in nn.Sequential)
      """
      if self.verbose:
          logging.info(
              "Building model trunk with %d stages..."
              % len(model_block_args)
          )
      self.in_chs = in_chs
      total_block_count = sum([len(x) for x in model_block_args])
      total_block_idx = 0
      current_stride = 2
      current_dilation = 1
      feature_idx = 0
      stages = []
      # outer list of block_args defines the stacks ('stages' by some conventions)
      for stage_idx, stage_block_args in enumerate(model_block_args):
          last_stack = stage_idx == (len(model_block_args) - 1)
          if self.verbose:
              self.logger.info("Stack: {}".format(stage_idx))
          assert isinstance(stage_block_args, list)
  
          # blocks = []
          # each stack (stage) contains a list of block arguments
          for block_idx, block_args in enumerate(stage_block_args):
              last_block = block_idx == (len(stage_block_args) - 1)
              if self.verbose:
                  self.logger.info(" Block: {}".format(block_idx))
  
              # Sort out stride, dilation, and feature extraction details
              assert block_args["stride"] in (1, 2)
              if block_idx >= 1:
                  # only the first block in any stack can have a stride > 1
                  block_args["stride"] = 1
  
              next_dilation = current_dilation
              if block_args["stride"] > 1:
                  next_output_stride = (
                      current_stride * block_args["stride"]
                  )
                  if next_output_stride > self.output_stride:
                      next_dilation = (
                          current_dilation * block_args["stride"]
                      )
                      block_args["stride"] = 1
                  else:
                      current_stride = next_output_stride
              block_args["dilation"] = current_dilation
              if next_dilation != current_dilation:
                  current_dilation = next_dilation
  
              if stage_idx == 0 or stage_idx == 6:
                  self.choice_num = 1
              else:
                  self.choice_num = len(self.choices)
  
                  if self.dil_conv:
                      self.choice_num += 2
  
              choice_blocks = []
              block_args_copy = deepcopy(block_args)
              if self.choice_num == 1:
                  # create the block
                  block = self._make_block(
                      block_args, 0, total_block_idx, total_block_count
                  )
                  choice_blocks.append(block)
              else:
                  for choice_idx, choice in enumerate(self.choices):
                      # create the block
                      block_args = deepcopy(block_args_copy)
                      block_args = modify_block_args(
                          block_args, choice[0], choice[1]
                      )
                      block = self._make_block(
                          block_args,
                          choice_idx,
                          total_block_idx,
                          total_block_count,
                      )
                      choice_blocks.append(block)
                  if self.dil_conv:
                      block_args = deepcopy(block_args_copy)
                      block_args = modify_block_args(block_args, 3, 0)
                      block = self._make_block(
                          block_args,
                          self.choice_num - 2,
                          total_block_idx,
                          total_block_count,
                          resunit=self.resunit,
                          dil_conv=self.dil_conv,
                      )
                      choice_blocks.append(block)
  
                      block_args = deepcopy(block_args_copy)
                      block_args = modify_block_args(block_args, 5, 0)
                      block = self._make_block(
                          block_args,
                          self.choice_num - 1,
                          total_block_idx,
                          total_block_count,
                          resunit=self.resunit,
                          dil_conv=self.dil_conv,
                      )
                      choice_blocks.append(block)
  
                  if self.resunit:
                      block = get_Bottleneck(
                          block.conv_pw.in_channels,
                          block.conv_pwl.out_channels,
                          block.conv_dw.stride[0],
                      )
                      choice_blocks.append(block)
  
              choice_block = mutables.LayerChoice(choice_blocks)
              stages.append(choice_block)
              # create the block
              # block = self._make_block(block_args, total_block_idx, total_block_count)
              total_block_idx += (
                  1  # incr global block idx (across all stacks)
              )
  
          # stages.append(blocks)
      return stages
  
file_path: nni/examples/nas/legacy/cream/lib/models/builders/build_supernet.py
imports: from copy import deepcopy
  from lib.utils.builder_util import modify_block_args
  from lib.models.blocks import get_Bottleneck, InvertedResidual
  from timm.models.efficientnet_blocks import *
  from nni.nas.pytorch import mutables
label_desc: Use image node_id 4 for calling the SuperNetBuilder obj's underlying member method code with example usage: obj.__call__(in_chs, model_block_args) and returns: stages