code: def _assert_itk_regions_match_array(image):
      # Note: Make it more compact? Also, are there redundant checks?
      largest_region = image.GetLargestPossibleRegion()
      buffered_region = image.GetBufferedRegion()
      requested_region = image.GetRequestedRegion()
  
      largest_region_size = np.array(largest_region.GetSize())
      buffered_region_size = np.array(buffered_region.GetSize())
      requested_region_size = np.array(requested_region.GetSize())
      array_size = np.array(image.shape)[::-1]
  
      largest_region_index = np.array(largest_region.GetIndex())
      buffered_region_index = np.array(buffered_region.GetIndex())
      requested_region_index = np.array(requested_region.GetIndex())
  
      indices_are_zeros = (
          np.all(largest_region_index == 0)
          and np.all(buffered_region_index == 0)
          and np.all(requested_region_index == 0)
      )
  
      sizes_match = (
          np.array_equal(array_size, largest_region_size)
          and np.array_equal(largest_region_size, buffered_region_size)
          and np.array_equal(
              buffered_region_size, requested_region_size
          )
      )
  
      if not indices_are_zeros:
          raise AssertionError(
              "ITK-MONAI bridge: non-zero ITK region indices encountered"
          )
      if not sizes_match:
          raise AssertionError(
              "ITK-MONAI bridge: ITK regions should be of the same shape"
          )
  
imports: from __future__ import annotations
  from typing import TYPE_CHECKING, cast
  import numpy
  import torch
  from monai.config.type_definitions import DtypeLike
  from monai.data import ITKReader, ITKWriter
  from monai.data.meta_tensor import MetaTensor
  from monai.data.utils import orientation_ras_lps
  from monai.transforms import EnsureChannelFirst
  from monai.utils import MetaKeys, SpaceKeys, convert_to_dst_type, optional_import
label_desc: Use image node_id 6 for calling a global function with example usage: _assert_itk_regions_match_array(image) without return types