class_docstr: A tf.TypeSpec for `AutoCompositeTensor` objects.
class_docstr_tok: ["A","tf.TypeSpec","for","`","AutoCompositeTensor","`","objects","."]
code: def from_instance(
      cls, instance, omit_kwargs=(), non_identifying_kwargs=()
  ):
      cls_value_type = cls.value_type.fget(None)
      if (
          type(instance) is not cls_value_type
      ):  # pylint: disable=unidiomatic-typecheck
          raise ValueError(
              f"`{type(instance).__name__}` has inherited the "
              f"`_type_spec` of `{cls_value_type.__name__}`. It "
              f"should define its own, either directly, or by "
              f"applying `auto_composite_tensor` to "
              f"`{type(instance).__name__}.`"
          )
      prefer_static_value = tuple(
          getattr(instance, "_composite_tensor_shape_params", ())
      )
      kwargs = _extract_init_kwargs(
          instance,
          omit_kwargs=omit_kwargs,
          prefer_static_value=prefer_static_value,
      )
  
      non_tensor_params = {}
      param_specs = {}
      callable_params = {}
      for k, v in list(kwargs.items()):
          # If v contains no Tensors, this will just be v
          type_spec_or_v = _extract_type_spec_recursively(v)
          if type_spec_or_v is not v:
              param_specs[k] = type_spec_or_v
          elif callable(v):
              callable_params[k] = v
          else:
              non_tensor_params[k] = v
  
      # Construct the spec.
      return cls(
          param_specs=param_specs,
          non_tensor_params=non_tensor_params,
          omit_kwargs=omit_kwargs,
          prefer_static_value=prefer_static_value,
          non_identifying_kwargs=non_identifying_kwargs,
          callable_params=callable_params,
      )
  
imports: import contextlib
  import functools
  import threading
  import numpy
  import tensorflow.compat.v2
  from tensorflow.python.framework import composite_tensor
  from tensorflow.python.framework import type_spec
  from tensorflow.python.framework import type_spec_registry
  from tensorflow.python.ops import resource_variable_ops
  from tensorflow.python.util import tf_inspect
  from tensorflow.python.util import variable_utils
label_desc: Use image node_id 2 for calling the _AutoCompositeTensorTypeSpec obj's underlying member method code with example usage: obj.from_instance(cls, instance, omit_kwargs, non_identifying_kwargs) and returns: cls