code: def get_spatial_dims(
      boxes: torch.Tensor | np.ndarray | None = None,
      points: torch.Tensor | np.ndarray | None = None,
      corners: Sequence | None = None,
      spatial_size: Sequence[int]
      | torch.Tensor
      | np.ndarray
      | None = None,
  ) -> int:
      """
      Get spatial dimension for the giving setting and check the validity of them.
      Missing input is allowed. But at least one of the input value should be given.
      It raises ValueError if the dimensions of multiple inputs do not match with each other.
  
      Args:
          boxes: bounding boxes, Nx4 or Nx6 torch tensor or ndarray
          points: point coordinates, [x, y] or [x, y, z], Nx2 or Nx3 torch tensor or ndarray
          corners: corners of boxes, 4-element or 6-element tuple, each element is a Nx1 torch tensor or ndarray
          spatial_size: The spatial size of the image where the boxes are attached.
                  len(spatial_size) should be in [2, 3].
  
      Returns:
          ``int``: spatial_dims, number of spatial dimensions of the bounding boxes.
  
      Example:
          .. code-block:: python
  
              boxes = torch.ones(10,6)
              get_spatial_dims(boxes, spatial_size=[100,200,200]) # will return 3
              get_spatial_dims(boxes, spatial_size=[100,200]) # will raise ValueError
              get_spatial_dims(boxes) # will return 3
      """
      spatial_dims_set = set()
  
      # Check the validity of each input and add its corresponding spatial_dims to spatial_dims_set
      if boxes is not None:
          if len(boxes.shape) != 2:
              if boxes.shape[0] == 0:
                  raise ValueError(
                      f"Currently we support only boxes with shape [N,4] or [N,6], "
                      f"got boxes with shape {boxes.shape}. "
                      f"Please reshape it with boxes = torch.reshape(boxes, [0, 4]) or torch.reshape(boxes, [0, 6])."
                  )
              else:
                  raise ValueError(
                      f"Currently we support only boxes with shape [N,4] or [N,6], got boxes with shape {boxes.shape}."
                  )
          if int(boxes.shape[1] / 2) not in SUPPORTED_SPATIAL_DIMS:
              raise ValueError(
                  f"Currently we support only boxes with shape [N,4] or [N,6], got boxes with shape {boxes.shape}."
              )
          spatial_dims_set.add(int(boxes.shape[1] / 2))
      if points is not None:
          if len(points.shape) != 2:
              if points.shape[0] == 0:
                  raise ValueError(
                      f"Currently we support only points with shape [N,2] or [N,3], "
                      f"got points with shape {points.shape}. "
                      f"Please reshape it with points = torch.reshape(points, [0, 2]) or torch.reshape(points, [0, 3])."
                  )
              else:
                  raise ValueError(
                      f"Currently we support only points with shape [N,2] or [N,3], got points with shape {points.shape}."
                  )
          if int(points.shape[1]) not in SUPPORTED_SPATIAL_DIMS:
              raise ValueError(
                  f"Currently we support only points with shape [N,2] or [N,3], got points with shape {points.shape}."
              )
          spatial_dims_set.add(int(points.shape[1]))
      if corners is not None:
          if len(corners) // 2 not in SUPPORTED_SPATIAL_DIMS:
              raise ValueError(
                  f"Currently we support only boxes with shape [N,4] or [N,6], got box corner tuple with length {len(corners)}."
              )
          spatial_dims_set.add(len(corners) // 2)
      if spatial_size is not None:
          if len(spatial_size) not in SUPPORTED_SPATIAL_DIMS:
              raise ValueError(
                  f"Currently we support only boxes on 2-D and 3-D images, got image spatial_size {spatial_size}."
              )
          spatial_dims_set.add(len(spatial_size))
  
      # Get spatial_dims from spatial_dims_set, which contains only unique values
      spatial_dims_list = list(spatial_dims_set)
      if len(spatial_dims_list) == 0:
          raise ValueError(
              "At least one of the inputs needs to be non-empty."
          )
  
      if len(spatial_dims_list) == 1:
          spatial_dims = int(spatial_dims_list[0])
          spatial_dims = look_up_option(spatial_dims, supported=[2, 3])
          return int(spatial_dims)
  
      raise ValueError(
          "The dimensions of multiple inputs should match with each other."
      )
  
imports: from __future__ import annotations
  import inspect
  import warnings
  from abc import ABC, abstractmethod
  from collections.abc import Callable, Sequence
  from copy import deepcopy
  import numpy
  import torch
  from monai.config.type_definitions import NdarrayOrTensor, NdarrayTensor
  from monai.utils import look_up_option
  from monai.utils.enums import BoxModeName
  from monai.utils.type_conversion import convert_data_type, convert_to_dst_type
label_desc: Use image node_id 1 for calling a global function with example usage: get_spatial_dims(boxes, points, corners, spatial_size) and returns: int