class_docstr: Analyzer to extract image stats properties for each case(image).
  
  Args:
      image_key: the key to find image data in the callable function input (data)
  
  Examples:
  
  .. code-block:: python
  
      import numpy as np
      from monai.auto3dseg import ImageStats
      from monai.data import MetaTensor
  
      input = {}
      input['image'] = np.random.rand(1,30,30,30)
      input['image'] = MetaTensor(np.random.rand(1,30,30,30))  # MetaTensor
      analyzer = ImageStats(image_key="image")
      print(analyzer(input)["image_stats"])
  
  Notes:
      if the image data is NumPy array, the spacing stats will be [1.0] * `ndims` of the array,
      where the `ndims` is the lesser value between the image dimension and 3.
class_docstr_tok: ["Analyzer","to","extract","image","stats","properties","for","each","case","(","image",")",".","Args",":","image_key",":","the","key","to","find","image","data","in","the","callable","function","input","(","data",")","Examples",":","..","code-block",":",":","python","import","numpy","as","np","from","monai.auto3dseg","import","ImageStats","from","monai.data","import","MetaTensor","input","=","{","}","input","[","'image","'","]","=","np.random.rand","(","1,30,30,30",")","input","[","'image","'","]","=","MetaTensor","(","np.random.rand","(","1,30,30,30",")",")","#","MetaTensor","analyzer","=","ImageStats","(","image_key=","''","image","''",")","print","(","analyzer","(","input",")","[","``","image_stats","''","]",")","Notes",":","if","the","image","data","is","NumPy","array",",","the","spacing","stats","will","be","[","1.0","]","*","`","ndims","`","of","the","array",",","where","the","`","ndims","`","is","the","lesser","value","between","the","image","dimension","and","3","."]
docstr: Callable to execute the pre-defined functions
  
  Returns:
      A dictionary. The dict has the key in self.report_format. The value of
      ImageStatsKeys.INTENSITY is in a list format. Each element of the value list
      has stats pre-defined by SampleOperations (max, min, ....).
  
  Raises:
      RuntimeError if the stats report generated is not consistent with the pre-
          defined report_format.
  
  Note:
      The stats operation uses numpy and torch to compute max, min, and other
      functions. If the input has nan/inf, the stats results will be nan/inf.
docstr_tok: ["Callable","to","execute","the","pre-defined","functions","Returns",":","A","dictionary",".","The","dict","has","the","key","in","self.report_format",".","The","value","of","ImageStatsKeys.INTENSITY","is","in","a","list","format",".","Each","element","of","the","value","list","has","stats","pre-defined","by","SampleOperations","(","max",",","min",",","....",")",".","Raises",":","RuntimeError","if","the","stats","report","generated","is","not","consistent","with","the","pre-","defined","report_format",".","Note",":","The","stats","operation","uses","numpy","and","torch","to","compute","max",",","min",",","and","other","functions",".","If","the","input","has","nan\/inf",",","the","stats","results","will","be","nan\/inf","."]
code: def __call__(self, data):
      """
      Callable to execute the pre-defined functions
  
      Returns:
          A dictionary. The dict has the key in self.report_format. The value of
          ImageStatsKeys.INTENSITY is in a list format. Each element of the value list
          has stats pre-defined by SampleOperations (max, min, ....).
  
      Raises:
          RuntimeError if the stats report generated is not consistent with the pre-
              defined report_format.
  
      Note:
          The stats operation uses numpy and torch to compute max, min, and other
          functions. If the input has nan/inf, the stats results will be nan/inf.
  
      """
      d = dict(data)
      start = time.time()
      restore_grad_state = torch.is_grad_enabled()
      torch.set_grad_enabled(False)
  
      ndas = [
          d[self.image_key][i]
          for i in range(d[self.image_key].shape[0])
      ]
      if "nda_croppeds" not in d:
          nda_croppeds = [get_foreground_image(nda) for nda in ndas]
  
      # perform calculation
      report = deepcopy(self.get_report_format())
  
      report[ImageStatsKeys.SHAPE] = [list(nda.shape) for nda in ndas]
      report[ImageStatsKeys.CHANNELS] = len(ndas)
      report[ImageStatsKeys.CROPPED_SHAPE] = [
          list(nda_c.shape) for nda_c in nda_croppeds
      ]
      report[ImageStatsKeys.SPACING] = (
          affine_to_spacing(data[self.image_key].affine).tolist()
          if isinstance(data[self.image_key], MetaTensor)
          else [1.0] * min(3, data[self.image_key].ndim)
      )
  
      report[ImageStatsKeys.SIZEMM] = [
          a * b
          for a, b in zip(
              report[ImageStatsKeys.SHAPE][0],
              report[ImageStatsKeys.SPACING],
          )
      ]
  
      report[ImageStatsKeys.INTENSITY] = [
          self.ops[ImageStatsKeys.INTENSITY].evaluate(nda_c)
          for nda_c in nda_croppeds
      ]
  
      if not verify_report_format(report, self.get_report_format()):
          raise RuntimeError(
              f"report generated by {self.__class__} differs from the report format."
          )
  
      d[self.stats_name] = report
  
      torch.set_grad_enabled(restore_grad_state)
      logger.debug(f"Get image stats spent {time.time()-start}")
      return d
  
imports: from __future__ import annotations
  import time
  from abc import ABC, abstractmethod
  from collections.abc import Hashable, Mapping
  from copy import deepcopy
  from typing import Any
  import numpy
  import torch
  from monai.apps.utils import get_logger
  from monai.auto3dseg.operations import Operations, SampleOperations, SummaryOperations
  from monai.auto3dseg.utils import concat_multikeys_to_dict, concat_val_to_np, get_foreground_image, get_foreground_label, get_label_ccp, verify_report_format
  from monai.bundle.config_parser import ConfigParser
  from monai.bundle.utils import ID_SEP_KEY
  from monai.data import MetaTensor, affine_to_spacing
  from monai.transforms.transform import MapTransform
  from monai.transforms.utils_pytorch_numpy_unification import sum, unique
  from monai.utils import convert_to_numpy
  from monai.utils.enums import DataStatsKeys, ImageStatsKeys, LabelStatsKeys
  from monai.utils.misc import ImageMetaKey, label_union
label_desc: Use image node_id 2 for calling the ImageStats obj's underlying member method code with example usage: obj.__call__(data) and returns: d