class_docstr: Upsample via using a subpixel CNN. This module supports 1D, 2D and 3D input images.
  The module is consisted with two parts. First of all, a convolutional layer is employed
  to increase the number of channels into: ``in_channels * (scale_factor ** dimensions)``.
  Secondly, a pixel shuffle manipulation is utilized to aggregates the feature maps from
  low resolution space and build the super resolution space.
  The first part of the module is not fixed, a sequential layers can be used to replace the
  default single layer.
  
  See: Shi et al., 2016, "Real-Time Single Image and Video Super-Resolution
  Using a nEfficient Sub-Pixel Convolutional Neural Network."
  
  See: Aitken et al., 2017, "Checkerboard artifact free sub-pixel convolution".
  
  The idea comes from:
  https://arxiv.org/abs/1609.05158
  
  The pixel shuffle mechanism refers to:
  https://pytorch.org/docs/stable/generated/torch.nn.PixelShuffle.html#torch.nn.PixelShuffle.
  and:
  https://github.com/pytorch/pytorch/pull/6340.
docstr: Args:
      spatial_dims: number of spatial dimensions of the input image.
      in_channels: number of channels of the input image.
      out_channels: optional number of channels of the output image.
      scale_factor: multiplier for spatial size. Defaults to 2.
      conv_block: a conv block to extract feature maps before upsampling. Defaults to None.
  
          - When ``conv_block`` is ``"default"``, one reserved conv layer will be utilized.
          - When ``conv_block`` is an ``nn.module``,
            please ensure the output number of channels is divisible ``(scale_factor ** dimensions)``.
  
      apply_pad_pool: if True the upsampled tensor is padded then average pooling is applied with a kernel the
          size of `scale_factor` with a stride of 1. This implements the nearest neighbour resize convolution
          component of subpixel convolutions described in Aitken et al.
      bias: whether to have a bias term in the default conv_block. Defaults to True.
docstr_tok: ["Args",":","spatial_dims",":","number","of","spatial","dimensions","of","the","input","image",".","in_channels",":","number","of","channels","of","the","input","image",".","out_channels",":","optional","number","of","channels","of","the","output","image",".","scale_factor",":","multiplier","for","spatial","size",".","Defaults","to","2.","conv_block",":","a","conv","block","to","extract","feature","maps","before","upsampling",".","Defaults","to","None",".","-","When","``","conv_block","``","is","``","``","default","''","``",",","one","reserved","conv","layer","will","be","utilized",".","-","When","``","conv_block","``","is","an","``","nn.module","``",",","please","ensure","the","output","number","of","channels","is","divisible","``","(","scale_factor","*","*","dimensions",")","``",".","apply_pad_pool",":","if","True","the","upsampled","tensor","is","padded","then","average","pooling","is","applied","with","a","kernel","the","size","of","`","scale_factor","`","with","a","stride","of","1",".","This","implements","the","nearest","neighbour","resize","convolution","component","of","subpixel","convolutions","described","in","Aitken","et","al",".","bias",":","whether","to","have","a","bias","term","in","the","default","conv_block",".","Defaults","to","True","."]
code: def __init__(
      self,
      spatial_dims: int,
      in_channels: int | None,
      out_channels: int | None = None,
      scale_factor: int = 2,
      conv_block: nn.Module | str | None = "default",
      apply_pad_pool: bool = True,
      bias: bool = True,
  ) -> None:
      """
      Args:
          spatial_dims: number of spatial dimensions of the input image.
          in_channels: number of channels of the input image.
          out_channels: optional number of channels of the output image.
          scale_factor: multiplier for spatial size. Defaults to 2.
          conv_block: a conv block to extract feature maps before upsampling. Defaults to None.
  
              - When ``conv_block`` is ``"default"``, one reserved conv layer will be utilized.
              - When ``conv_block`` is an ``nn.module``,
                please ensure the output number of channels is divisible ``(scale_factor ** dimensions)``.
  
          apply_pad_pool: if True the upsampled tensor is padded then average pooling is applied with a kernel the
              size of `scale_factor` with a stride of 1. This implements the nearest neighbour resize convolution
              component of subpixel convolutions described in Aitken et al.
          bias: whether to have a bias term in the default conv_block. Defaults to True.
  
      """
      super().__init__()
  
      if scale_factor <= 0:
          raise ValueError(
              f"The `scale_factor` multiplier must be an integer greater than 0, got {scale_factor}."
          )
  
      self.dimensions = spatial_dims
      self.scale_factor = scale_factor
  
      if conv_block == "default":
          out_channels = out_channels or in_channels
          if not out_channels:
              raise ValueError("in_channels need to be specified.")
          conv_out_channels = out_channels * (
              scale_factor**self.dimensions
          )
          self.conv_block = Conv[Conv.CONV, self.dimensions](
              in_channels=in_channels,
              out_channels=conv_out_channels,
              kernel_size=3,
              stride=1,
              padding=1,
              bias=bias,
          )
  
          icnr_init(self.conv_block, self.scale_factor)
      elif conv_block is None:
          self.conv_block = nn.Identity()
      else:
          self.conv_block = conv_block
  
      self.pad_pool: nn.Module = nn.Identity()
  
      if apply_pad_pool:
          pool_type = Pool[Pool.AVG, self.dimensions]
          pad_type = Pad[Pad.CONSTANTPAD, self.dimensions]
  
          self.pad_pool = nn.Sequential(
              pad_type(
                  padding=(self.scale_factor - 1, 0) * self.dimensions,
                  value=0.0,
              ),
              pool_type(kernel_size=self.scale_factor, stride=1),
          )
  
file_path: MONAI/monai/networks/blocks/upsample.py
imports: from __future__ import annotations
  from collections.abc import Sequence
  import torch
  import torch.nn
  from monai.networks.layers.factories import Conv, Pad, Pool
  from monai.networks.utils import icnr_init, pixelshuffle
  from monai.utils import InterpolateMode, UpsampleMode, ensure_tuple_rep, look_up_option
label_desc: Use image node_id 1 to create a new SubpixelUpsample object from inherited base classes: nn with example: obj = SubpixelUpsample(spatial_dims, in_channels, out_channels, scale_factor, conv_block, apply_pad_pool, bias)