class_docstr: A container for all capture usages within FuncGraph.
docstr: Captures `tensor` if it's external to this graph.
  
  If `tensor` is from a different graph, returns a placeholder for it.
  `tensor` and the placeholder will appear in self.captures, and the
  placeholder will appear in self.inputs.  Multiple calls to this method with
  the same `tensor` argument will return the same placeholder. If `tensor` is
  from this graph, returns `tensor`.
  
  Args:
    graph: The FuncGraph that captures this tensor.
    tensor: Tensor. May be from this FuncGraph or a different graph.
    name: Optional name if a placeholder is created.
  
  Returns:
    Tensor from this FuncGraph.
  
  Raises:
    InaccessibleTensorError: if any tensors are accessed in a manner that
    bypasses the mechanisms required for the data dependencies to be correctly
    wired.
code: def capture_by_value(
      self, graph: Any, tensor: core.Tensor, name: Optional[str] = None
  ) -> core.Tensor:
      """Captures `tensor` if it's external to this graph.
  
      If `tensor` is from a different graph, returns a placeholder for it.
      `tensor` and the placeholder will appear in self.captures, and the
      placeholder will appear in self.inputs.  Multiple calls to this method with
      the same `tensor` argument will return the same placeholder. If `tensor` is
      from this graph, returns `tensor`.
  
      Args:
        graph: The FuncGraph that captures this tensor.
        tensor: Tensor. May be from this FuncGraph or a different graph.
        name: Optional name if a placeholder is created.
  
      Returns:
        Tensor from this FuncGraph.
  
      Raises:
        InaccessibleTensorError: if any tensors are accessed in a manner that
        bypasses the mechanisms required for the data dependencies to be correctly
        wired.
      """
      if isinstance(tensor, core.Value):
          if name is None:
              # A unique (within the program execution) integer.
              name = str(pywrap_tfe.TFE_Py_UID())
  
          # Small EagerTensors are captured with Const ops
          if (
              tensor.dtype in dtypes.TF_VALUE_DTYPES
              and functools.reduce(lambda a, b: a * b, tensor.shape, 1)
              <= _EAGER_CONST_THRESHOLD
          ):
              graph_const = self.by_val_internal.get(id(tensor))
              if graph_const is None:
                  graph_const = tensor._capture_as_const(
                      name
                  )  # pylint: disable=protected-access
                  if graph_const is None:
                      # Some eager tensors, e.g. parallel tensors, are not convertible to
                      # a single constant. We'll use a placeholder for this case.
                      graph_const = self._create_placeholder_helper(
                          graph, tensor, name
                      )
                  self.add_or_replace(
                      key=id(tensor),
                      external=tensor,
                      internal=graph_const,
                      is_by_ref=False,
                  )
                  graph.inputs.append(graph_const)
              graph_const._record_tape(
                  tensor
              )  # pylint: disable=protected-access
              return graph_const
  
          # Large EagerTensors and resources are captured with Placeholder ops
          return self._create_placeholder_helper(graph, tensor, name)
  
      if tensor.graph is not graph:
          graph._validate_in_scope(
              tensor
          )  # pylint: disable=protected-access
          if name is None:
              assert tensor.op is not None, (
                  tensor.__class__,
                  dir(tensor),
                  tensor.__class__.__name__,
              )
              name = tensor.op.name
          # cond/while graphs override _capture_helper() so cannot call
          # self.create_placeholder_helper() here directly.
          return graph._capture_helper(
              tensor, name
          )  # pylint: disable=protected-access
      return tensor
  
imports: import collections
  import functools
  from typing import Any, Callable, Hashable, Mapping, Optional
  from tensorflow.core.function import trace_type
  from tensorflow.python import pywrap_tfe
  from tensorflow.python.framework import dtypes
  from tensorflow.python.types import core
  from tensorflow.python.util import object_identity
label_desc: Use image node_id 3 for calling the FunctionCaptures obj's underlying member method code with example usage: obj.capture_by_value(graph, tensor, name) and returns: tensor, self, graph, graph_const