code: def orientation(
      img, original_affine, spatial_ornt, lazy, transform_info
  ) -> torch.Tensor:
      """
      Functional implementation of changing the input image's orientation into the specified based on `spatial_ornt`.
      This function operates eagerly or lazily according to
      ``lazy`` (default ``False``).
  
      Args:
          img: data to be changed, assuming `img` is channel-first.
          original_affine: original affine of the input image.
          spatial_ornt: orientations of the spatial axes,
              see also https://nipy.org/nibabel/reference/nibabel.orientations.html
          lazy: a flag that indicates whether the operation should be performed lazily or not
          transform_info: a dictionary with the relevant information pertaining to an applied transform.
      """
      spatial_shape = (
          img.peek_pending_shape()
          if isinstance(img, MetaTensor)
          else img.shape[1:]
      )
      xform = nib.orientations.inv_ornt_aff(spatial_ornt, spatial_shape)
      img = convert_to_tensor(img, track_meta=get_track_meta())
  
      spatial_ornt[:, 0] += 1  # skip channel dim
      spatial_ornt = np.concatenate([np.array([[0, 1]]), spatial_ornt])
      axes = [
          ax for ax, flip in enumerate(spatial_ornt[:, 1]) if flip == -1
      ]
      full_transpose = np.arange(
          len(spatial_shape) + 1
      )  # channel-first array
      full_transpose[: len(spatial_ornt)] = np.argsort(
          spatial_ornt[:, 0]
      )
      extra_info = {"original_affine": original_affine}
  
      shape_np = convert_to_numpy(spatial_shape, wrap_sequence=True)
      shape_np = shape_np[[i - 1 for i in full_transpose if i > 0]]
      meta_info = TraceableTransform.track_transform_meta(
          img,
          sp_size=shape_np,
          affine=xform,
          extra_info=extra_info,
          orig_size=spatial_shape,
          transform_info=transform_info,
          lazy=lazy,
      )
      out = _maybe_new_metatensor(img)
      if lazy:
          return out.copy_meta_from(meta_info) if isinstance(out, MetaTensor) else meta_info  # type: ignore
      if axes:
          out = torch.flip(out, dims=axes)
      if not np.all(full_transpose == np.arange(len(out.shape))):
          out = out.permute(full_transpose.tolist())
      return (
          out.copy_meta_from(meta_info)
          if isinstance(out, MetaTensor)
          else out
      )
  
imports: from __future__ import annotations
  import math
  import warnings
  from enum import Enum
  import numpy
  import torch
  import monai
  from monai.config import USE_COMPILED
  from monai.config.type_definitions import NdarrayOrTensor
  from monai.data.meta_obj import get_track_meta
  from monai.data.meta_tensor import MetaTensor
  from monai.data.utils import AFFINE_TOL, compute_shape_offset, to_affine_nd
  from monai.networks.layers import AffineTransform
  from monai.transforms.croppad.array import ResizeWithPadOrCrop
  from monai.transforms.intensity.array import GaussianSmooth
  from monai.transforms.inverse import TraceableTransform
  from monai.transforms.utils import create_rotate, create_translate, resolves_modes, scale_affine
  from monai.transforms.utils_pytorch_numpy_unification import allclose
  from monai.utils import LazyAttr, TraceKeys, convert_to_dst_type, convert_to_numpy, convert_to_tensor, ensure_tuple, ensure_tuple_rep, fall_back_tuple, optional_import
label_desc: Use image node_id 3 for calling a global function with example usage: orientation(img, original_affine, spatial_ornt, lazy, transform_info) and returns: unknown, unknown