class_docstr: `FeatureConnector` for integer class labels.
code: def encode_example(self, example_data):
      if self._num_classes is None:
          raise ValueError(
              "Trying to use ClassLabel feature with undefined number of class. "
              "Please set ClassLabel.names or num_classes."
          )
  
      # If a string is given, convert to associated integer
      if isinstance(example_data, str):
          example_data = self.str2int(example_data)
      elif isinstance(example_data, bytes):
          # Accept bytes if user yield `tensor.numpy()`
          # Python 3 doesn't interpret byte strings as strings directly.
          example_data = self.str2int(example_data.decode("utf-8"))
  
      # Allowing -1 to mean no label.
      if not -1 <= example_data < self._num_classes:
          raise ValueError(
              "Class label %d greater than configured num_classes %d"
              % (example_data, self._num_classes)
          )
      return example_data
  
imports: from typing import Optional, Union
  from etils import epath
  import numpy
  from tensorflow_datasets.core.features import feature
  from tensorflow_datasets.core.features import tensor_feature
  from tensorflow_datasets.core.proto import feature_pb2
  from tensorflow_datasets.core.utils import type_utils
label_desc: Use image node_id 7 for calling the ClassLabel obj's underlying member method code with example usage: obj.encode_example(example_data) and returns: example_data