class_docstr: Image with additional label metadata.
  
  This feature connector is similar to `tfds.features.Image`, but expose
  additional attributes from `tfds.features.ClassLabel` to access label
  metadata.
  
  This can be used for segmentation tasks were each pixel is labeled.
  
  ```python
  builder = tfds.builder('my_dataset')
  builder.info.features['label_image'].names == ['background', 'car', ...]
  ```
class_docstr_tok: ["Image","with","additional","label","metadata",".","This","feature","connector","is","similar","to","`","tfds.features.Image","`",",","but","expose","additional","attributes","from","`","tfds.features.ClassLabel","`","to","access","label","metadata",".","This","can","be","used","for","segmentation","tasks","were","each","pixel","is","labeled",".","``","`","python","builder","=","tfds.builder","(","'my_dataset","'",")","builder.info.features","[","'label_image","'","]",".names","==","[","'background","'",",","'car","'",",","...","]","``","`"]
docstr: Constructor.
  
  Labels can be defined as:
  
  * `List[str]` (e.g. `['background', 'car', 'truck', ...]`): The list of
    label strings.
  * `PathLike` (e.g. `'/path/to/label.txt'`): A file containing the labels
    (one per-line).
  * `int` (e.g. `12`): The total number of labels, if the actual label names
    string are unknown (discouraged).
  * `None`: If the number of label is unknown (discouraged).
  
  Args:
    labels: Labels metadata (see docstring above)
    shape: Image shape (see `tfds.features.Image.__init__`)
    dtype: Image dtype (see `tfds.features.Image.__init__`)
    encoding_format: 'jpeg' or 'png' (see `tfds.features.Image.__init__`)
    doc: Documentation of this feature (e.g. description).
docstr_tok: ["Constructor",".","Labels","can","be","defined","as",":","*","`","List","[","str","]","`","(","e.g",".","`","[","'background","'",",","'car","'",",","'truck","'",",","...","]","`",")",":","The","list","of","label","strings",".","*","`","PathLike","`","(","e.g",".","`","'\/path\/to\/label.txt","'","`",")",":","A","file","containing","the","labels","(","one","per-line",")",".","*","`","int","`","(","e.g",".","`","12","`",")",":","The","total","number","of","labels",",","if","the","actual","label","names","string","are","unknown","(","discouraged",")",".","*","`","None","`",":","If","the","number","of","label","is","unknown","(","discouraged",")",".","Args",":","labels",":","Labels","metadata","(","see","docstring","above",")","shape",":","Image","shape","(","see","`","tfds.features.Image.__init__","`",")","dtype",":","Image","dtype","(","see","`","tfds.features.Image.__init__","`",")","encoding_format",":","'jpeg","'","or","'png","'","(","see","`","tfds.features.Image.__init__","`",")","doc",":","Documentation","of","this","feature","(","e.g",".","description",")","."]
code: def __init__(
      self,
      *,
      labels: _LabelArg,
      shape: Optional[type_utils.Shape] = None,
      dtype: Optional[type_utils.TfdsDType] = None,
      encoding_format: Optional[str] = None,
      doc: feature_lib.DocArg = None,
  ):
      """Constructor.
  
      Labels can be defined as:
  
      * `List[str]` (e.g. `['background', 'car', 'truck', ...]`): The list of
        label strings.
      * `PathLike` (e.g. `'/path/to/label.txt'`): A file containing the labels
        (one per-line).
      * `int` (e.g. `12`): The total number of labels, if the actual label names
        string are unknown (discouraged).
      * `None`: If the number of label is unknown (discouraged).
  
      Args:
        labels: Labels metadata (see docstring above)
        shape: Image shape (see `tfds.features.Image.__init__`)
        dtype: Image dtype (see `tfds.features.Image.__init__`)
        encoding_format: 'jpeg' or 'png' (see `tfds.features.Image.__init__`)
        doc: Documentation of this feature (e.g. description).
      """
      super().__init__(
          # Label images have a single channel
          shape=shape or (None, None, 1),
          dtype=dtype,
          encoding_format=encoding_format,
          use_colormap=True,  # LabeledImage always use colormap
          doc=doc,
      )
      if self.shape[-1] != 1:
          raise ValueError(
              f"LabeledImage shape should have a single channel. Got: {shape}"
          )
      label_kwargs = _labels_to_kwarg(labels)
      self._class_label = class_label_feature.ClassLabel(**label_kwargs)
  
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 to create a new LabeledImage object from inherited base classes: image_feature with example: obj = LabeledImage()