code: def validate_labels_format(labels, task_type: TaskType):
      """Validate that the labels are in the required format based on task_type.
  
      Parameters
      ----------
      labels
          The labels of the batch. Result of VisionData's batch_to_labels
      task_type: TaskType
          The task type of the model
      Raises
      ------
      DeepchecksValueError
          If the labels doesn't fit the required deepchecks format.
      """
      single_image_label = _validate_predictions_label_common_format(
          "label", labels, task_type
      )
  
      if (
          task_type == TaskType.CLASSIFICATION
          and single_image_label is not None
      ):
          if not isinstance(single_image_label, Number):
              raise ValidationError(
                  "Classification label per image must be a number."
              )
      elif (
          task_type == TaskType.OBJECT_DETECTION
          and single_image_label is not None
      ):
          error_msg = (
              "Object detection label per image must be a sequence of 2D arrays, where each row "
              "has 5 columns: [class_id, x_min, y_min, width, height]"
          )
          if single_image_label.shape[1] != 5:
              raise ValidationError(f"{error_msg}")
          if np.min(single_image_label) < 0:
              raise ValidationError(
                  f"Found one of coordinates to be negative, {error_msg}"
              )
          if np.max(single_image_label[:, 0] % 1) > 0:
              raise ValidationError(
                  f"Class_id must be a positive integer. {error_msg}"
              )
      elif (
          task_type == TaskType.SEMANTIC_SEGMENTATION
          and single_image_label is not None
      ):
          if len(single_image_label.shape) != 2:
              raise ValidationError(
                  "Semantic segmentation label per image must be a 2D array of shape (H, W),"
                  "where H and W are the height and width of the corresponding image."
              )
          if np.max(single_image_label % 1) > 0:
              raise ValidationError(
                  "In semantic segmentation, each pixel in label should represent a "
                  "class_id and there must be a positive integer."
              )
  
file_path: deepchecks/deepchecks/vision/vision_data/format_validators.py
imports: from numbers import Number
  from typing import Iterable
  import numpy
  from deepchecks.core.errors import ValidationError
  from deepchecks.vision.vision_data import TaskType
  from deepchecks.vision.vision_data.utils import object_to_numpy, sequence_to_numpy
label_desc: Use image node_id 2 for calling a global function with example usage: validate_labels_format(labels, task_type) without return types