code: def _uniform_crop_helper(
      images: torch.Tensor, size: int, spatial_idx: int
  ):
      """
      A helper function grouping the common components in uniform crop
      """
      assert spatial_idx in [0, 1, 2]
      height = images.shape[2]
      width = images.shape[3]
  
      y_offset = int(math.ceil((height - size) / 2))
      x_offset = int(math.ceil((width - size) / 2))
  
      if height > width:
          if spatial_idx == 0:
              y_offset = 0
          elif spatial_idx == 2:
              y_offset = height - size
      else:
          if spatial_idx == 0:
              x_offset = 0
          elif spatial_idx == 2:
              x_offset = width - size
      cropped = images[
          :, :, y_offset : y_offset + size, x_offset : x_offset + size
      ]
  
      return cropped, x_offset, y_offset
  
imports: import copy
  import math
  from typing import Tuple
  import numpy
  import torch
label_desc: Use image node_id 9 for calling a global function with example usage: _uniform_crop_helper(images, size, spatial_idx) and returns: cropped,  x_offset,  y_offset