class_docstr: Abstract base class for Tensor-like objects that are composed from Tensors.
  
  Each `CompositeTensor` can be decomposed into a structured collection of
  component `tf.Tensor`s, and reconstructed from those components.
  
  The `tensorflow.python.util.nest` module has support for treating composite
  tensors as structure, which makes it easy to flatten and reconstruct
  composite tensors (or larger structures that contain composite tensors).
  E.g.:
  
  ```python
  ct = ...  # Create a composite tensor.
  flat_list_of_tensors = nest.flatten(ct, expand_composites=True)
  transformed_list_of_tensors = ...  # do something with the flat tensors.
  result = nest.pack_sequence_as(ct, transformed_list_of_tensors,
                                 expand_composites=True)
  ```
docstr: Returns a TypeSpec given a shape invariant (used by `tf.while_loop`).
  
  Args:
    shape: A `tf.TensorShape` object.  The shape invariant for this
      `CompositeTensor`, or `None` if a default shape invariant should be used
      (based on the value of this `CompositeTensor`).
  
  Returns:
    A nested structure whose values are `tf.TensorShape` objects, specifying
    the shape invariants for the tensors that comprise this `CompositeTensor`.
code: def _shape_invariant_to_type_spec(self, shape):
      """Returns a TypeSpec given a shape invariant (used by `tf.while_loop`).
  
      Args:
        shape: A `tf.TensorShape` object.  The shape invariant for this
          `CompositeTensor`, or `None` if a default shape invariant should be used
          (based on the value of this `CompositeTensor`).
  
      Returns:
        A nested structure whose values are `tf.TensorShape` objects, specifying
        the shape invariants for the tensors that comprise this `CompositeTensor`.
      """
      # New TypeSpec subclasses generally do not need to implement this --
      # this method is used for backwards compatibility.  Users of tf.while_loop
      # can specify a type by passing in TypeSpec instead.
      raise NotImplementedError(
          f"{type(self).__name__}._shape_invariant_to_type_spec"
      )
  
file_path: tensorflow-upstream/tensorflow/python/framework/composite_tensor.py
imports: import abc
  from tensorflow.python import pywrap_tensorflow
  from tensorflow.python.util import nest
  from tensorflow.python.util.tf_export import tf_export
label_desc: Use image node_id 2 for calling the CompositeTensor obj's underlying member method code with example usage: obj._shape_invariant_to_type_spec(shape) without return types