class_docstr: Represents the type of object(s) for tf.function tracing purposes.
  
  `TraceType` is an abstract class that other classes might inherit from to
  provide information regarding associated class(es) for the purposes of
  tf.function tracing. The typing logic provided through this mechanism will be
  used to make decisions regarding usage of cached concrete functions and
  retracing.
  
  For example, if we have the following tf.function and classes:
  ```python
  @tf.function
  def get_mixed_flavor(fruit_a, fruit_b):
    return fruit_a.flavor + fruit_b.flavor
  
  class Fruit:
    flavor = tf.constant([0, 0])
  
  class Apple(Fruit):
    flavor = tf.constant([1, 2])
  
  class Mango(Fruit):
    flavor = tf.constant([3, 4])
  ```
  
  tf.function does not know when to re-use an existing concrete function in
  regards to the `Fruit` class so naively it retraces for every new instance.
  ```python
  get_mixed_flavor(Apple(), Mango()) # Traces a new concrete function
  get_mixed_flavor(Apple(), Mango()) # Traces a new concrete function again
  ```
  
  However, we, as the designers of the `Fruit` class, know that each subclass
  has a fixed flavor and we can reuse an existing traced concrete function if
  it was the same subclass. Avoiding such unnecessary tracing of concrete
  functions can have significant performance benefits.
  
  ```python
  class FruitTraceType(tf.types.experimental.TraceType):
    def __init__(self, fruit):
      self.fruit_type = type(fruit)
      self.fruit_value = fruit
  
    def is_subtype_of(self, other):
       return (type(other) is FruitTraceType and
               self.fruit_type is other.fruit_type)
  
    def most_specific_common_supertype(self, others):
       return self if all(self == other for other in others) else None
  
    def placeholder_value(self, placeholder_context=None):
      return self.fruit_value
  
  class Fruit:
  
   def __tf_tracing_type__(self, context):
     return FruitTraceType(self)
  ```
  
  Now if we try calling it again:
  ```python
  get_mixed_flavor(Apple(), Mango()) # Traces a new concrete function
  get_mixed_flavor(Apple(), Mango()) # Re-uses the traced concrete function
  ```
docstr: Cast value to this type.
  
  Args:
    value: An input value belonging to this TraceType.
    cast_context: A context reserved for internal/future usage.
  
  Returns:
    The value casted to this TraceType.
  
  Raises:
    AssertionError: When _cast is not overloaded in subclass,
      the value is returned directly, and it should be the same to
      self.placeholder_value().
docstr_tok: ["Cast","value","to","this","type",".","Args",":","value",":","An","input","value","belonging","to","this","TraceType",".","cast_context",":","A","context","reserved","for","internal\/future","usage",".","Returns",":","The","value","casted","to","this","TraceType",".","Raises",":","AssertionError",":","When","_cast","is","not","overloaded","in","subclass",",","the","value","is","returned","directly",",","and","it","should","be","the","same","to","self.placeholder_value","(",")","."]
code: def cast(self, value, cast_context) -> Any:
      """Cast value to this type.
  
      Args:
        value: An input value belonging to this TraceType.
        cast_context: A context reserved for internal/future usage.
  
      Returns:
        The value casted to this TraceType.
  
      Raises:
        AssertionError: When _cast is not overloaded in subclass,
          the value is returned directly, and it should be the same to
          self.placeholder_value().
      """
      del cast_context
      assert value == self.placeholder_value(
          PlaceholderContext()
      ), f"Can not cast {value!r} to type {self!r}"
      return value
  
imports: import abc
  from typing import Any, Iterator, List, Optional, Sequence
  from typing_extensions import Protocol
  from typing_extensions import runtime_checkable
  from tensorflow.python.types import core
  from tensorflow.python.util.tf_export import tf_export
  from tensorflow.tools.docs import doc_controls
label_desc: Use image node_id 7 for calling the TraceType obj's underlying member method code with example usage: obj.cast(value, cast_context) and returns: value