class_docstr: `FeatureConnector` for generic data of arbitrary shape and type.
docstr: See base class for details.
docstr_tok: ["See","base","class","for","details","."]
code: def encode_example(self, example_data):
      """See base class for details."""
      # TODO(epot): Is there a better workaround ?
      # It seems some user have non-conventional use of tfds.features.Tensor where
      # they defined shape=(None, None) even if it wasn't supported.
      # For backward compatibility, the check is moved inside encode example.
      if self._dynamic_shape and not self._encoded_to_bytes:
          raise ValueError(
              "Multiple unknown dimensions Tensor require to set "
              "`Tensor(..., encoding='zlib')` (or 'bytes'). "
              f"For {self}"
          )
  
      np_dtype = self._serialized_dtype
      if np_dtype == np.bool_ and isinstance(example_data, str):
          raise TypeError(
              f"Error encoding: {example_data!r}. {example_data!r} is a string, so "
              "converting it to `bool` will always output `True`. Please, fix "
              "`_generate_examples` with a better parsing."
          )
      if enp.lazy.has_tf and isinstance(example_data, tf.Tensor):
          raise TypeError(
              f"Error encoding: {example_data!r}. `_generate_examples` should "
              "yield `np.array` compatible values, not `tf.Tensor`"
          )
      if not isinstance(example_data, np.ndarray):
          example_data = np.array(example_data, dtype=np_dtype)
      # Ensure the shape and dtype match
      if example_data.dtype != np_dtype:
          raise ValueError(
              "Dtype {} do not match {}".format(
                  example_data.dtype, np_dtype
              )
          )
  
      shape = example_data.shape
  
      utils.assert_shape_match(shape, self._serialized_shape)
  
      # Eventually encode the data
      if self._encoded_to_bytes:
          example_data = example_data.tobytes()
          if self._encoding == Encoding.ZLIB:
              example_data = zlib.compress(example_data)
  
      # For dynamically shaped tensors, also save the shape (the proto
      # flatten all values so we need a way to recover the shape).
      if self._dynamic_shape:
          return {
              "value": example_data,
              "shape": shape,
          }
      else:
          return example_data
  
imports: from __future__ import annotations
  import enum
  import functools
  from typing import Optional, Protocol, Tuple, TypeVar, Union
  import zlib
  from etils import enp
  import numpy
  from tensorflow_datasets.core import utils
  from tensorflow_datasets.core.features import feature
  from tensorflow_datasets.core.proto import feature_pb2
  from tensorflow_datasets.core.utils import dtype_utils
  from tensorflow_datasets.core.utils import np_utils
  from tensorflow_datasets.core.utils import py_utils
  from tensorflow_datasets.core.utils import type_utils
  from tensorflow_datasets.core.utils.lazy_imports_utils import tensorflow
label_desc: Use image node_id 4 for calling the Tensor obj's underlying member method code with example usage: obj.encode_example(example_data) and returns: dict, example_data