class_docstr: Checks if segmentation label images (in keys) have the same spatial shape as the main image (in source_key),
  and raise an error if the shapes are significantly different.
  If the shapes are only slightly different (within an allowed_shape_difference in each dim), then resize the label using
  nearest interpolation. This transform is designed to correct datasets with slight label shape mismatches.
  Generally image and segmentation label must have the same spatial shape, however some public datasets are having slight
  shape mismatches, which will cause potential crashes when calculating loss or metric functions.
class_docstr_tok: ["Checks","if","segmentation","label","images","(","in","keys",")","have","the","same","spatial","shape","as","the","main","image","(","in","source_key",")",",","and","raise","an","error","if","the","shapes","are","significantly","different",".","If","the","shapes","are","only","slightly","different","(","within","an","allowed_shape_difference","in","each","dim",")",",","then","resize","the","label","using","nearest","interpolation",".","This","transform","is","designed","to","correct","datasets","with","slight","label","shape","mismatches",".","Generally","image","and","segmentation","label","must","have","the","same","spatial","shape",",","however","some","public","datasets","are","having","slight","shape","mismatches",",","which","will","cause","potential","crashes","when","calculating","loss","or","metric","functions","."]
docstr: Args:
      keys: keys of the corresponding items to be compared to the source_key item shape.
      allow_missing_keys: do not raise exception if key is missing.
      source_key: key of the item with the reference shape.
      allowed_shape_difference: raises error if shapes are different more than this value in any dimension,
          otherwise corrects for the shape mismatch using nearest interpolation.
      warn: if `True` prints a warning if the label image is resized
docstr_tok: ["Args",":","keys",":","keys","of","the","corresponding","items","to","be","compared","to","the","source_key","item","shape",".","allow_missing_keys",":","do","not","raise","exception","if","key","is","missing",".","source_key",":","key","of","the","item","with","the","reference","shape",".","allowed_shape_difference",":","raises","error","if","shapes","are","different","more","than","this","value","in","any","dimension",",","otherwise","corrects","for","the","shape","mismatch","using","nearest","interpolation",".","warn",":","if","`","True","`","prints","a","warning","if","the","label","image","is","resized"]
code: def __init__(
      self,
      keys: KeysCollection = "label",
      allow_missing_keys: bool = False,
      source_key: str = "image",
      allowed_shape_difference: int = 5,
      warn: bool = True,
  ) -> None:
      """
      Args:
          keys: keys of the corresponding items to be compared to the source_key item shape.
          allow_missing_keys: do not raise exception if key is missing.
          source_key: key of the item with the reference shape.
          allowed_shape_difference: raises error if shapes are different more than this value in any dimension,
              otherwise corrects for the shape mismatch using nearest interpolation.
          warn: if `True` prints a warning if the label image is resized
  
  
      """
      super().__init__(keys=keys, allow_missing_keys=allow_missing_keys)
      self.source_key = source_key
      self.allowed_shape_difference = allowed_shape_difference
      self.warn = warn
  
file_path: MONAI/monai/apps/auto3dseg/transforms.py
imports: from __future__ import annotations
  import warnings
  from collections.abc import Hashable, Mapping
  import numpy
  import torch
  from monai.config import KeysCollection
  from monai.networks.utils import pytorch_after
  from monai.transforms import MapTransform
  from monai.utils.misc import ImageMetaKey
label_desc: Use image node_id 1 to create a new EnsureSameShaped object from inherited base classes: MapTransform with example: obj = EnsureSameShaped(keys, allow_missing_keys, source_key, allowed_shape_difference, warn)