code: def _item_to_tf_feature(
      item, tensor_info: feature_lib.TensorInfo
  ) -> tf.train.Feature:
      """Single item to a tf.train.Feature."""
      v = _item_to_np_array(
          item,
          shape=tensor_info.shape,
          dtype=tensor_info.np_dtype,
      )
  
      # Convert boolean to integer (tf.train.Example does not support bool)
      if v.dtype == np.bool_:
          v = v.astype(int)
  
      vals = v.flat  # Convert v into a 1-d array (without extra copy)
      if dtype_utils.is_integer(v.dtype):
          return tf_feature_pb2.Feature(
              int64_list=tf_feature_pb2.Int64List(value=vals)
          )
      elif dtype_utils.is_floating(v.dtype):
          return tf_feature_pb2.Feature(
              float_list=tf_feature_pb2.FloatList(value=vals)
          )
      elif dtype_utils.is_string(tensor_info.np_dtype):
          vals = [_as_bytes(x) for x in vals]
          return tf_feature_pb2.Feature(
              bytes_list=tf_feature_pb2.BytesList(value=vals)
          )
      else:
          raise ValueError(
              "Unsupported value: {}.\n"
              "tf_feature_pb2.Feature does not support type {}. "
              "This may indicate that one of the FeatureConnectors received an "
              "unsupported value as input.".format(
                  repr(v), repr(type(v))
              )
          )
  
imports: from __future__ import annotations
  import abc
  import collections
  import dataclasses
  from typing import Any, Mapping, Union
  import numpy
  from tensorflow_datasets.core import utils
  from tensorflow_datasets.core.features import feature
  from tensorflow_datasets.core.utils import dtype_utils
  from tensorflow_datasets.core.utils.lazy_imports_utils import tensorflow
  from tensorflow_datasets.proto import tf_example_pb2
  from tensorflow_datasets.proto import tf_feature_pb2
label_desc: Use image node_id 4 for calling a global function with example usage: _item_to_tf_feature(item, tensor_info) and returns: tf_feature_pb2, tf_feature_pb2, tf_feature_pb2