class_docstr: The backbone network used in VoxelMorph. See :py:class:`monai.networks.nets.VoxelMorph` for more details.
  
  A concatenated pair of images (moving and fixed) is first passed through a UNet. The output of the UNet is then
  passed through a series of convolution blocks to produce the final prediction of the displacement field (DDF) or the
  stationary velocity field (DVF).
  
  In the original implementation, downsample is achieved through maxpooling, here one has the option to use either
  maxpooling or strided convolution for downsampling. The default is to use maxpooling as it is consistent with the
  original implementation. Note that for upsampling, the authors of VoxelMorph used nearest neighbor interpolation
  instead of transposed convolution. In this implementation, only nearest neighbor interpolation is supported in order
  to be consistent with the original implementation.
  
  An instance of this class can be used as a backbone network for constructing a VoxelMorph network. See the
  documentation of :py:class:`monai.networks.nets.VoxelMorph` for more details and an example on how to construct a
  VoxelMorph network.
  
  Args:
      spatial_dims: number of spatial dimensions.
      in_channels: number of channels in the input volume after concatenation of moving and fixed images.
      unet_out_channels: number of channels in the output of the UNet.
      channels: number of channels in each layer of the UNet. See the following example for more details.
      final_conv_channels: number of channels in each layer of the final convolution block.
      final_conv_act: activation type for the final convolution block. Defaults to LeakyReLU.
          Since VoxelMorph was originally implemented in tensorflow where the default negative slope for
          LeakyReLU was 0.2, we use the same default value here.
      kernel_size: kernel size for all convolution layers in the UNet. Defaults to 3.
      up_kernel_size: kernel size for all convolution layers in the upsampling path of the UNet. Defaults to 3.
      act: activation type for all convolution layers in the UNet. Defaults to LeakyReLU with negative slope 0.2.
      norm: feature normalization type and arguments for all convolution layers in the UNet. Defaults to None.
      dropout: dropout ratio for all convolution layers in the UNet. Defaults to 0.0 (no dropout).
      bias: whether to use bias in all convolution layers in the UNet. Defaults to True.
      use_maxpool: whether to use maxpooling in the downsampling path of the UNet. Defaults to True.
          Using maxpooling is the consistent with the original implementation of VoxelMorph.
          But one can optionally use strided convolution instead (i.e. set `use_maxpool` to False).
      adn_ordering: ordering of activation, dropout, and normalization. Defaults to "NDA".
class_docstr_tok: ["The","backbone","network","used","in","VoxelMorph",".","See",":","py",":","class",":","`","monai.networks.nets.VoxelMorph","`","for","more","details",".","A","concatenated","pair","of","images","(","moving","and","fixed",")","is","first","passed","through","a","UNet",".","The","output","of","the","UNet","is","then","passed","through","a","series","of","convolution","blocks","to","produce","the","final","prediction","of","the","displacement","field","(","DDF",")","or","the","stationary","velocity","field","(","DVF",")",".","In","the","original","implementation",",","downsample","is","achieved","through","maxpooling",",","here","one","has","the","option","to","use","either","maxpooling","or","strided","convolution","for","downsampling",".","The","default","is","to","use","maxpooling","as","it","is","consistent","with","the","original","implementation",".","Note","that","for","upsampling",",","the","authors","of","VoxelMorph","used","nearest","neighbor","interpolation","instead","of","transposed","convolution",".","In","this","implementation",",","only","nearest","neighbor","interpolation","is","supported","in","order","to","be","consistent","with","the","original","implementation",".","An","instance","of","this","class","can","be","used","as","a","backbone","network","for","constructing","a","VoxelMorph","network",".","See","the","documentation","of",":","py",":","class",":","`","monai.networks.nets.VoxelMorph","`","for","more","details","and","an","example","on","how","to","construct","a","VoxelMorph","network",".","Args",":","spatial_dims",":","number","of","spatial","dimensions",".","in_channels",":","number","of","channels","in","the","input","volume","after","concatenation","of","moving","and","fixed","images",".","unet_out_channels",":","number","of","channels","in","the","output","of","the","UNet",".","channels",":","number","of","channels","in","each","layer","of","the","UNet",".","See","the","following","example","for","more","details",".","final_conv_channels",":","number","of","channels","in","each","layer","of","the","final","convolution","block",".","final_conv_act",":","activation","type","for","the","final","convolution","block",".","Defaults","to","LeakyReLU",".","Since","VoxelMorph","was","originally","implemented","in","tensorflow","where","the","default","negative","slope","for","LeakyReLU","was","0.2",",","we","use","the","same","default","value","here",".","kernel_size",":","kernel","size","for","all","convolution","layers","in","the","UNet",".","Defaults","to","3.","up_kernel_size",":","kernel","size","for","all","convolution","layers","in","the","upsampling","path","of","the","UNet",".","Defaults","to","3.","act",":","activation","type","for","all","convolution","layers","in","the","UNet",".","Defaults","to","LeakyReLU","with","negative","slope","0.2.","norm",":","feature","normalization","type","and","arguments","for","all","convolution","layers","in","the","UNet",".","Defaults","to","None",".","dropout",":","dropout","ratio","for","all","convolution","layers","in","the","UNet",".","Defaults","to","0.0","(","no","dropout",")",".","bias",":","whether","to","use","bias","in","all","convolution","layers","in","the","UNet",".","Defaults","to","True",".","use_maxpool",":","whether","to","use","maxpooling","in","the","downsampling","path","of","the","UNet",".","Defaults","to","True",".","Using","maxpooling","is","the","consistent","with","the","original","implementation","of","VoxelMorph",".","But","one","can","optionally","use","strided","convolution","instead","(","i.e",".","set","`","use_maxpool","`","to","False",")",".","adn_ordering",":","ordering","of","activation",",","dropout",",","and","normalization",".","Defaults","to","``","NDA","''","."]
docstr: In each down layer, the input is first downsampled using maxpooling,
  then passed through a convolution block, unless this is the top layer
  in which case the input is passed through a convolution block only
  without maxpooling first.
  
  Args:
      in_channels: number of input channels.
      out_channels: number of output channels.
      is_top: True if this is the top block.
docstr_tok: ["In","each","down","layer",",","the","input","is","first","downsampled","using","maxpooling",",","then","passed","through","a","convolution","block",",","unless","this","is","the","top","layer","in","which","case","the","input","is","passed","through","a","convolution","block","only","without","maxpooling","first",".","Args",":","in_channels",":","number","of","input","channels",".","out_channels",":","number","of","output","channels",".","is_top",":","True","if","this","is","the","top","block","."]
code: def _get_down_layer(
      self, in_channels: int, out_channels: int, is_top: bool
  ) -> nn.Module:
      """
      In each down layer, the input is first downsampled using maxpooling,
      then passed through a convolution block, unless this is the top layer
      in which case the input is passed through a convolution block only
      without maxpooling first.
  
      Args:
          in_channels: number of input channels.
          out_channels: number of output channels.
          is_top: True if this is the top block.
      """
  
      mod: Convolution | nn.Sequential
  
      strides = 1 if self.use_maxpool or is_top else 2
  
      mod = Convolution(
          self.dimensions,
          in_channels,
          out_channels,
          strides=strides,
          kernel_size=self.kernel_size,
          act=self.act,
          norm=self.norm,
          dropout=self.dropout,
          bias=self.bias,
          adn_ordering=self.adn_ordering,
      )
  
      if self.use_maxpool and not is_top:
          mod = (
              nn.Sequential(nn.MaxPool3d(kernel_size=2, stride=2), mod)
              if self.dimensions == 3
              else nn.Sequential(
                  nn.MaxPool2d(kernel_size=2, stride=2), mod
              )
          )
  
      return mod
  
imports: from __future__ import annotations
  from collections.abc import Sequence
  import torch
  import torch.nn
  import torch.nn.functional
  from monai.networks.blocks.convolutions import Convolution
  from monai.networks.blocks.upsample import UpSample
  from monai.networks.blocks.warp import DVF2DDF, Warp
  from monai.networks.layers.simplelayers import SkipConnection
  from monai.utils import alias, export
label_desc: Use image node_id 3 for calling the VoxelMorphUNet obj's underlying member method code with example usage: obj._get_down_layer(in_channels, out_channels, is_top) and returns: mod