def METHOD_NAME(label_map):
    """Checks if a label map is valid.
    Args:
      label_map: StringIntLabelMap to validate.
    Raises:
      ValueError: if label map is invalid.
    """
    for item in label_map.item:
        if item.id < 0:
            raise ValueError("Label map ids should be >= 0.")
        if item.id == 0 and item.name != "background":
            raise ValueError("Label map id 0 is reserved for the background label")