code: def _labels_to_kwarg(labels: _LabelArg) -> dict[str, _LabelArg]:
      """Creates the `ClassLabel.__init__` kwargs."""
      if labels is None:
          return {}
      elif isinstance(labels, int):
          kwarg_name = "num_classes"
      elif isinstance(labels, epath.PathLikeCls):
          kwarg_name = "names_file"
      elif isinstance(labels, list):
          kwarg_name = "names"
      else:
          raise TypeError(
              f"Invalid `labels` type: {type(labels)}. Should be one of "
              "list[labels], path, num_labels"
          )
      return {kwarg_name: labels}
  
file_path: datasets/tensorflow_datasets/core/features/labeled_image.py
imports: from __future__ import annotations
  from typing import Optional, Union
  from etils import epath
  from tensorflow_datasets.core.features import class_label_feature
  from tensorflow_datasets.core.features import feature
  from tensorflow_datasets.core.features import image_feature
  from tensorflow_datasets.core.proto import feature_pb2
  from tensorflow_datasets.core.utils import type_utils
label_desc: Use image node_id 1 for calling a global function with example usage: _labels_to_kwarg(labels) and returns: dict, dict