class_docstr: SegResEncoder based on the encoder structure in `3D MRI brain tumor segmentation using autoencoder regularization
  <https://arxiv.org/pdf/1810.11654.pdf>`_.
  
  Args:
      spatial_dims: spatial dimension of the input data. Defaults to 3.
      init_filters: number of output channels for initial convolution layer. Defaults to 32.
      in_channels: number of input channels for the network. Defaults to 1.
      out_channels: number of output channels for the network. Defaults to 2.
      act: activation type and arguments. Defaults to ``RELU``.
      norm: feature normalization type and arguments. Defaults to ``BATCH``.
      blocks_down: number of downsample blocks in each layer. Defaults to ``[1,2,2,4]``.
      head_module: optional callable module to apply to the final features.
      anisotropic_scales: optional list of scale for each scale level.
class_docstr_tok: ["SegResEncoder","based","on","the","encoder","structure","in","`","3D","MRI","brain","tumor","segmentation","using","autoencoder","regularization","<","https",":","\/\/arxiv.org\/pdf\/1810.11654.pdf",">","`","_",".","Args",":","spatial_dims",":","spatial","dimension","of","the","input","data",".","Defaults","to","3.","init_filters",":","number","of","output","channels","for","initial","convolution","layer",".","Defaults","to","32.","in_channels",":","number","of","input","channels","for","the","network",".","Defaults","to","1.","out_channels",":","number","of","output","channels","for","the","network",".","Defaults","to","2.","act",":","activation","type","and","arguments",".","Defaults","to","``","RELU","``",".","norm",":","feature","normalization","type","and","arguments",".","Defaults","to","``","BATCH","``",".","blocks_down",":","number","of","downsample","blocks","in","each","layer",".","Defaults","to","``","[","1,2,2,4","]","``",".","head_module",":","optional","callable","module","to","apply","to","the","final","features",".","anisotropic_scales",":","optional","list","of","scale","for","each","scale","level","."]
code: def __init__(
      self,
      spatial_dims: int = 3,
      init_filters: int = 32,
      in_channels: int = 1,
      act: tuple | str = "relu",
      norm: tuple | str = "batch",
      blocks_down: tuple = (1, 2, 2, 4),
      head_module: nn.Module | None = None,
      anisotropic_scales: tuple | None = None,
  ):
      super().__init__()
  
      if spatial_dims not in (1, 2, 3):
          raise ValueError("`spatial_dims` can only be 1, 2 or 3.")
  
      # ensure normalization has affine trainable parameters (if not specified)
      norm = split_args(norm)
      if has_option(Norm[norm[0], spatial_dims], "affine"):
          norm[1].setdefault("affine", True)  # type: ignore
  
      # ensure activation is inplace (if not specified)
      act = split_args(act)
      if has_option(Act[act[0]], "inplace"):
          act[1].setdefault("inplace", True)  # type: ignore
  
      filters = init_filters  # base number of features
  
      kernel_size, padding, _ = (
          aniso_kernel(anisotropic_scales[0])
          if anisotropic_scales
          else (3, 1, 1)
      )
      self.conv_init = Conv[Conv.CONV, spatial_dims](
          in_channels=in_channels,
          out_channels=filters,
          kernel_size=kernel_size,
          padding=padding,
          stride=1,
          bias=False,
      )
      self.layers = nn.ModuleList()
  
      for i in range(len(blocks_down)):
          level = nn.ModuleDict()
  
          kernel_size, padding, stride = (
              aniso_kernel(anisotropic_scales[i])
              if anisotropic_scales
              else (3, 1, 2)
          )
          blocks = [
              SegResBlock(
                  spatial_dims=spatial_dims,
                  in_channels=filters,
                  kernel_size=kernel_size,
                  norm=norm,
                  act=act,
              )
              for _ in range(blocks_down[i])
          ]
          level["blocks"] = nn.Sequential(*blocks)
  
          if i < len(blocks_down) - 1:
              level["downsample"] = Conv[Conv.CONV, spatial_dims](
                  in_channels=filters,
                  out_channels=2 * filters,
                  bias=False,
                  kernel_size=kernel_size,
                  stride=stride,
                  padding=padding,
              )
          else:
              level["downsample"] = nn.Identity()
  
          self.layers.append(level)
          filters *= 2
  
      self.head_module = head_module
      self.in_channels = in_channels
      self.blocks_down = blocks_down
      self.init_filters = init_filters
      self.norm = norm
      self.act = act
      self.spatial_dims = spatial_dims
  
imports: from __future__ import annotations
  from collections.abc import Callable
  from typing import Union
  import numpy
  import torch
  import torch.nn
  from monai.networks.blocks.upsample import UpSample
  from monai.networks.layers.factories import Act, Conv, Norm, split_args
  from monai.networks.layers.utils import get_act_layer, get_norm_layer
  from monai.utils import UpsampleMode, has_option
label_desc: Use image node_id 1 to create a new SegResEncoder object from inherited base classes: nn with example: obj = SegResEncoder(spatial_dims, init_filters, in_channels, act, norm, blocks_down, head_module, anisotropic_scales)