code: def switch_endianness(data, new="<"):
      """
      Convert the input `data` endianness to `new`.
  
      Args:
          data: input to be converted.
          new: the target endianness, currently support "<" or ">".
      """
      if isinstance(data, torch.Tensor):
          device = data.device
          requires_grad: bool = data.requires_grad
          data = (
              torch.from_numpy(
                  switch_endianness(data.cpu().detach().numpy(), new)
              )
              .to(device)
              .requires_grad_(requires_grad=requires_grad)  # type: ignore
          )
      elif isinstance(data, np.ndarray):
          # default to system endian
          sys_native = "<" if (sys.byteorder == "little") else ">"
          current_ = (
              sys_native
              if data.dtype.byteorder not in ("<", ">")
              else data.dtype.byteorder
          )
          if new not in ("<", ">"):
              raise NotImplementedError(
                  f"Not implemented option new={new}."
              )
          if current_ != new:
              data = data.byteswap().newbyteorder(new)
      elif isinstance(data, tuple):
          data = tuple(switch_endianness(x, new) for x in data)
      elif isinstance(data, list):
          data = [switch_endianness(x, new) for x in data]
      elif isinstance(data, dict):
          data = {k: switch_endianness(v, new) for k, v in data.items()}
      elif not isinstance(data, (bool, str, float, int, type(None))):
          raise RuntimeError(f"Unknown type: {type(data).__name__}")
      return data
  
imports: from __future__ import annotations
  import inspect
  import logging
  import sys
  import traceback
  import warnings
  from collections.abc import Sequence
  from pathlib import Path
  from pydoc import locate
  from typing import Callable
  import numpy
  import torch
  from monai.config import DtypeLike, NdarrayOrTensor, PathLike
  from monai.data import image_writer
  from monai.data.folder_layout import FolderLayout, FolderLayoutBase, default_name_formatter
  from monai.data.image_reader import ImageReader, ITKReader, NibabelReader, NrrdReader, NumpyReader, PILReader, PydicomReader
  from monai.data.meta_tensor import MetaTensor
  from monai.data.utils import is_no_channel
  from monai.transforms.transform import Transform
  from monai.transforms.utility.array import EnsureChannelFirst
  from monai.utils import GridSamplePadMode
  from monai.utils import ImageMetaKey
  from monai.utils import OptionalImportError, convert_to_dst_type, ensure_tuple, look_up_option, optional_import
label_desc: Use image node_id 1 for calling a global function with example usage: switch_endianness(data, new) and returns: data