code: def analyze_data(
      datalist_json: dict, data_dir: str
  ) -> tuple[int, int]:
      """
      Analyze (training) data
  
      Args:
          datalist_json: original data list .json (required by most monai tutorials).
          data_dir: raw data directory.
      """
      img = monai.transforms.LoadImage(
          image_only=True, ensure_channel_first=True, simple_keys=True
      )(os.path.join(data_dir, datalist_json["training"][0]["image"]))
      num_input_channels = img.size()[0] if img.dim() == 4 else 1
      logger.info(f"num_input_channels: {num_input_channels}")
  
      num_foreground_classes = 0
      for _i in range(len(datalist_json["training"])):
          seg = monai.transforms.LoadImage(
              image_only=True,
              ensure_channel_first=True,
              simple_keys=True,
          )(
              os.path.join(
                  data_dir, datalist_json["training"][_i]["label"]
              )
          )
          num_foreground_classes = max(
              num_foreground_classes, int(seg.max())
          )
      logger.info(f"num_foreground_classes: {num_foreground_classes}")
  
      return num_input_channels, num_foreground_classes
  
file_path: MONAI/monai/apps/nnunet/utils.py
imports: from __future__ import annotations
  import copy
  import os
  import numpy
  import monai
  from monai.bundle import ConfigParser
  from monai.utils import StrEnum, ensure_tuple, optional_import
label_desc: Use image node_id 1 for calling a global function with example usage: analyze_data(datalist_json, data_dir) and returns: num_input_channels,  num_foreground_classes