code: def pixelshuffle(
      x: torch.Tensor, spatial_dims: int, scale_factor: int
  ) -> torch.Tensor:
      """
      Apply pixel shuffle to the tensor `x` with spatial dimensions `spatial_dims` and scaling factor `scale_factor`.
  
      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".
  
      Args:
          x: Input tensor
          spatial_dims: number of spatial dimensions, typically 2 or 3 for 2D or 3D
          scale_factor: factor to rescale the spatial dimensions by, must be >=1
  
      Returns:
          Reshuffled version of `x`.
  
      Raises:
          ValueError: When input channels of `x` are not divisible by (scale_factor ** spatial_dims)
      """
      dim, factor = spatial_dims, scale_factor
      input_size = list(x.size())
      batch_size, channels = input_size[:2]
      scale_divisor = factor**dim
  
      if channels % scale_divisor != 0:
          raise ValueError(
              f"Number of input channels ({channels}) must be evenly "
              f"divisible by scale_factor ** dimensions ({factor}**{dim}={scale_divisor})."
          )
  
      org_channels = int(channels // scale_divisor)
      output_size = [batch_size, org_channels] + [
          d * factor for d in input_size[2:]
      ]
  
      indices = list(range(2, 2 + 2 * dim))
      indices = indices[dim:] + indices[:dim]
      permute_indices = [0, 1]
      for idx in range(dim):
          permute_indices.extend(indices[idx::dim])
  
      x = x.reshape(
          [batch_size, org_channels] + [factor] * dim + input_size[2:]
      )
      x = x.permute(permute_indices).reshape(output_size)
      return x
  
imports: from __future__ import annotations
  import io
  import re
  import warnings
  from collections import OrderedDict
  from collections.abc import Callable, Mapping, Sequence
  from contextlib import contextmanager
  from copy import deepcopy
  from typing import Any
  import numpy
  import torch
  import torch.nn
  from monai.apps.utils import get_logger
  from monai.config import PathLike
  from monai.utils.misc import ensure_tuple, save_obj, set_determinism
  from monai.utils.module import look_up_option, optional_import, pytorch_after
  from monai.utils.type_conversion import convert_to_dst_type, convert_to_tensor
label_desc: Use image node_id 10 for calling a global function with example usage: pixelshuffle(x, spatial_dims, scale_factor) and returns: x