class_docstr: `FeatureConnector` for generic data of arbitrary shape and type.
docstr: Construct a Tensor feature.
  
  Args:
    shape: Tensor shape
    dtype: Tensor dtype
    encoding: Internal encoding. See `tfds.features.Encoding` for available
      values.
    doc: Documentation of this feature (e.g. description).
    serialized_dtype: Tensor dtype. Used to validate that serialized examples
      have this dtype. If `None` then defaults to `dtype`
    serialized_shape: Tensor shape. Used to validate that serialized examples
      have this shape. If `None` then defaults to `shape`
docstr_tok: ["Construct","a","Tensor","feature",".","Args",":","shape",":","Tensor","shape","dtype",":","Tensor","dtype","encoding",":","Internal","encoding",".","See","`","tfds.features.Encoding","`","for","available","values",".","doc",":","Documentation","of","this","feature","(","e.g",".","description",")",".","serialized_dtype",":","Tensor","dtype",".","Used","to","validate","that","serialized","examples","have","this","dtype",".","If","`","None","`","then","defaults","to","`","dtype","`","serialized_shape",":","Tensor","shape",".","Used","to","validate","that","serialized","examples","have","this","shape",".","If","`","None","`","then","defaults","to","`","shape","`"]
code: def __init__(
      self,
      *,
      shape: utils.Shape,
      dtype: type_utils.TfdsDType,
      # TODO(tfds): Could add an Encoding.AUTO to automatically compress
      # tensors using some heuristic. However, careful about backward
      # compatibility.
      # Would require some `DatasetInfo.api_version = 1` which would be
      # increased when triggering backward-incompatible changes.
      encoding: Union[str, Encoding] = Encoding.NONE,
      doc: feature_lib.DocArg = None,
      serialized_dtype: Optional[type_utils.TfdsDType] = None,
      serialized_shape: Optional[utils.Shape] = None,
  ):
      """Construct a Tensor feature.
  
      Args:
        shape: Tensor shape
        dtype: Tensor dtype
        encoding: Internal encoding. See `tfds.features.Encoding` for available
          values.
        doc: Documentation of this feature (e.g. description).
        serialized_dtype: Tensor dtype. Used to validate that serialized examples
          have this dtype. If `None` then defaults to `dtype`
        serialized_shape: Tensor shape. Used to validate that serialized examples
          have this shape. If `None` then defaults to `shape`
      """
      super().__init__(doc=doc)
      self._shape = tuple(shape)
      self._dtype = dtype_utils.cast_to_numpy(dtype)
      self._serialized_dtype = dtype_utils.cast_to_numpy(
          serialized_dtype or self._dtype
      )
      self._serialized_shape = tuple(
          self._shape if serialized_shape is None else serialized_shape
      )
      if isinstance(encoding, str):
          encoding = encoding.lower()
      self._encoding = Encoding(encoding)
  
      self._encoded_to_bytes = self._encoding != Encoding.NONE
      self._dynamic_shape = self._shape.count(None) > 1
  
      if dtype_utils.is_string(self._dtype) and self._encoded_to_bytes:
          raise NotImplementedError(
              "tfds.features.Tensor() does not support `encoding=` when "
              "dtype is string. Please open a PR if you need this feature."
          )
  
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 1 to create a new Tensor object from inherited base classes: feature_lib with example: obj = Tensor()