docstr: Get the number of classes for given data.
  
  Parameters
  ----------
      sample_data_path
          This is used for automatically inference num_classes of semantic segmentation dataset.
          Could be an image directory, image file or pd.DataFrame.
  Returns
  -------
      The number of classes.
code: def get_semantic_segmentation_class_num(self, sample_data_path):
      """
      Get the number of classes for given data.
  
      Parameters
      ----------
          sample_data_path
              This is used for automatically inference num_classes of semantic segmentation dataset.
              Could be an image directory, image file or pd.DataFrame.
      Returns
      -------
          The number of classes.
      """
      if isinstance(sample_data_path, str):
          if os.path.isdir(sample_data_path):
              mask_files = os.listdir(sample_data_path)
              num_classes = []
              for mask_file in mask_files:
                  per_num_classes = (
                      self.get_semantic_segmentation_class_num(
                          os.path.join(sample_data_path, mask_file)
                      )
                  )
                  num_classes.append(per_num_classes)
              return max(num_classes)
          else:
              mask = Image.open(sample_data_path)
              mode = mask.mode
  
              if mode == "1":
                  return 1
              classes = np.unique(mask)
              if mode == "L" and np.array_equal(
                  classes, np.array([0, 255])
              ):
                  return 1
  
              return max(classes).item() + 1  # include background
  
      elif isinstance(sample_data_path, pd.DataFrame):
          num_classes = []
          for idx in range(sample_data_path.shape[0]):
              row = sample_data_path.iloc[idx]
              mask_file = row[self._label_column]
              per_num_classes = (
                  self.get_semantic_segmentation_class_num(mask_file)
              )
              num_classes.append(per_num_classes)
          return max(num_classes)
  
imports: import logging
  import os
  from typing import Dict, Iterable, List, Optional, Union
  import matplotlib.pyplot
  import numpy
  import pandas
  import torch
  import torch.nn.functional
  from omegaconf import OmegaConf
  from PIL import Image
  from scipy.special import softmax
  from autogluon.core.metrics import Scorer
  from ..constants import LABEL, LOGITS, SEMANTIC_MASK, SEMANTIC_SEGMENTATION, SEMANTIC_SEGMENTATION_IMG
  from ..optimization.lit_semantic_seg import SemanticSegmentationLitModule
  from ..optimization.semantic_seg_metrics import Balanced_Error_Rate_Pred
  from ..optimization.semantic_seg_metrics import Binary_IoU_Pred
  from ..optimization.semantic_seg_metrics import COD_METRICS_NAMES_Pred
  from ..optimization.semantic_seg_metrics import Multiclass_IoU_Pred
  from ..optimization.utils import get_loss_func, get_norm_layer_param_names, get_trainable_params_efficient_finetune
  from ..utils import extract_from_output, setup_save_path
  from .base import BaseLearner
  from ..constants import BER, EM, FM, IOU, MAE, SEMANTIC_SEGMENTATION, SM
label_desc: Use image node_id 2 for calling the SemanticSegmentationLearner obj's underlying member method code with example usage: obj.get_semantic_segmentation_class_num(sample_data_path) and returns: max, unknown, max, int, int