code: def assert_valid_class_labels(
      y: np.ndarray,
      allow_missing_classes: bool = True,
      allow_one_class: bool = False,
  ) -> None:
      """Checks that ``labels`` is properly formatted, i.e. a 1D numpy array where labels are zero-based
      integers (not multi-label).
      """
      if y.ndim != 1:
          raise ValueError("Labels must be 1D numpy array.")
      if any([isinstance(label, str) for label in y]):
          raise ValueError(
              "Labels cannot be strings, they must be zero-indexed integers corresponding to class indices."
          )
      if not np.equal(
          np.mod(y, 1), 0
      ).all():  # check that labels are integers
          raise ValueError(
              "Labels must be zero-indexed integers corresponding to class indices."
          )
      if min(y) < 0:
          raise ValueError(
              "Labels must be positive integers corresponding to class indices."
          )
  
      unique_classes = np.unique(y)
      if (not allow_one_class) and (len(unique_classes) < 2):
          raise ValueError("Labels must contain at least 2 classes.")
  
      if not allow_missing_classes:
          if (unique_classes != np.arange(len(unique_classes))).any():
              msg = "cleanlab requires zero-indexed integer labels (0,1,2,..,K-1), but in "
              msg += "your case: np.unique(labels) = {}. ".format(
                  str(unique_classes)
              )
              msg += "Every class in (0,1,2,..,K-1) must be present in labels as well."
              raise TypeError(msg)
  
file_path: cleanlab/cleanlab/internal/validation.py
imports: from cleanlab.typing import LabelLike, DatasetLike
  from cleanlab.internal.constants import FLOATING_POINT_COMPARISON
  from typing import Any, List, Optional, Union
  import warnings
  import numpy
  import pandas
label_desc: Use image node_id 2 for calling a global function with example usage: assert_valid_class_labels(y, allow_missing_classes, allow_one_class) without return types