class_docstr: An up-sample module that can be used for LocalNet, based on:
  `Weakly-supervised convolutional neural networks for multimodal image registration
  <https://doi.org/10.1016/j.media.2018.07.002>`_.
  `Label-driven weakly-supervised learning for multimodal deformable image registration
  <https://arxiv.org/abs/1711.01666>`_.
  
  Adapted from:
      DeepReg (https://github.com/DeepRegNet/DeepReg)
docstr: Halves the channel and doubles the spatial dimensions.
  
  Args:
      x: feature to be up-sampled, in shape (batch, ``in_channels``, insize_1, insize_2, [insize_3])
      mid: mid-level feature saved during down-sampling,
          in shape (batch, ``out_channels``, midsize_1, midsize_2, [midsize_3])
  
  Raises:
      ValueError: when ``midsize != insize * 2``
docstr_tok: ["Halves","the","channel","and","doubles","the","spatial","dimensions",".","Args",":","x",":","feature","to","be","up-sampled",",","in","shape","(","batch",",","``","in_channels","``",",","insize_1",",","insize_2",",","[","insize_3","]",")","mid",":","mid-level","feature","saved","during","down-sampling",",","in","shape","(","batch",",","``","out_channels","``",",","midsize_1",",","midsize_2",",","[","midsize_3","]",")","Raises",":","ValueError",":","when","``","midsize","!","=","insize","*","2","``"]
code: def forward(self, x, mid) -> torch.Tensor:
      """
      Halves the channel and doubles the spatial dimensions.
  
      Args:
          x: feature to be up-sampled, in shape (batch, ``in_channels``, insize_1, insize_2, [insize_3])
          mid: mid-level feature saved during down-sampling,
              in shape (batch, ``out_channels``, midsize_1, midsize_2, [midsize_3])
  
      Raises:
          ValueError: when ``midsize != insize * 2``
      """
      for i, j in zip(x.shape[2:], mid.shape[2:]):
          if j != 2 * i:
              raise ValueError(
                  "expecting mid spatial dimensions be exactly the double of x spatial dimensions, "
                  f"got x of shape {x.shape}, mid of shape {mid.shape}"
              )
      h0 = self.deconv_block(x) + self.additive_upsampling(x, mid)
      r1 = h0 + mid
      r2 = self.conv_block(h0)
      out: torch.Tensor = self.residual_block(r2, r1)
      return out
  
imports: from __future__ import annotations
  from collections.abc import Sequence
  import torch
  from torch import nn
  from torch.nn import functional
  from monai.networks.blocks import Convolution
  from monai.networks.layers import same_padding
  from monai.networks.layers.factories import Conv, Norm, Pool
label_desc: Use image node_id 3 for calling the LocalNetUpSampleBlock obj's underlying member method code with example usage: obj.forward(x, mid) and returns: out