code: def _transpose_spatial_inputs(inputs):
      num_spatial_dims = inputs.ndim - 2
      # Torch pooling does not support `channels_last` format, so
      # we need to transpose to `channels_first` format.
      if num_spatial_dims == 1:
          inputs = torch.permute(inputs, (0, 2, 1))
      elif num_spatial_dims == 2:
          inputs = torch.permute(inputs, (0, 3, 1, 2))
      elif num_spatial_dims == 3:
          inputs = torch.permute(inputs, (0, 4, 1, 2, 3))
      else:
          raise ValueError(
              "Inputs must have ndim=3, 4 or 5, "
              "corresponding to 1D, 2D and 3D inputs. "
              f"Received input shape: {inputs.shape}."
          )
      return inputs
  
imports: import torch
  import torch.nn.functional
  import tree
  from keras.backend import standardize_data_format
  from keras.backend import standardize_dtype
  from keras.backend.common.backend_utils import compute_conv_transpose_padding_args_for_torch
  from keras.backend.config import epsilon
  from keras.backend.torch.core import cast
  from keras.backend.torch.core import convert_to_tensor
  from keras.backend.torch.core import get_device
  from keras.backend.torch.numpy import expand_dims
  from keras.backend.torch.numpy import maximum
  from keras.backend.torch.numpy import where
  from keras.utils.argument_validation import standardize_tuple
label_desc: Use image node_id 19 for calling a global function with example usage: _transpose_spatial_inputs(inputs) and returns: inputs