class_docstr: A wrapper for a function owned by an EagerPyFunc.
class_docstr_tok: ["A","wrapper","for","a","function","owned","by","an","EagerPyFunc","."]
docstr: Converts `value` to a tensor of type `dtype`, with error checking.
  
  Args:
    value: The tensor to convert.
    dtype: The desired dtype.
  
  Returns:
    A tensor of type `dtype`, or a zeros tensor if value is None and
    this function is in fact a gradient function.
  
  Raises:
    RuntimeError: if `value` is a variable.
code: def _convert(self, value, dtype):
      """Converts `value` to a tensor of type `dtype`, with error checking.
  
      Args:
        value: The tensor to convert.
        dtype: The desired dtype.
  
      Returns:
        A tensor of type `dtype`, or a zeros tensor if value is None and
        this function is in fact a gradient function.
  
      Raises:
        RuntimeError: if `value` is a variable.
      """
  
      if isinstance(value, resource_variable_ops.ResourceVariable):
          raise RuntimeError(
              "Attempting to return a variable from an eagerly executed py_func. "
              "Only numeric data structures like Tensors or NumPy arrays should "
              "be returned; to return the value of a variable, make sure to obtain "
              "the Tensor backing it by calling `.read_value()` on the variable in "
              f"question: {value}"
          )
      if value is None and self._is_grad_func:
          # Gradient functions may legitimately return a list that contains
          # both Tensors and Python Nones. Unfortunately this breaks the
          # OpKernel, so for now we replace None objects with zeros, which is
          # mathematically correct but will prevent short-circuiting gradient
          # computations.
          #
          # TODO(akshayka): Make it possible to return a list of both Tensors and
          # Nones from an EagerPyFunc.
          return constant_op.constant(0.0, dtype=dtype)
      return ops.convert_to_tensor(value, dtype=dtype)
  
imports: import functools
  import threading
  import traceback
  import weakref
  import numpy
  from tensorflow.python.autograph.impl import api
  from tensorflow.python.eager import backprop
  from tensorflow.python.eager import backprop_util
  from tensorflow.python.eager import context
  from tensorflow.python.eager import record
  from tensorflow.python.framework import composite_tensor
  from tensorflow.python.framework import constant_op
  from tensorflow.python.framework import dtypes
  from tensorflow.python.framework import func_graph
  from tensorflow.python.framework import function
  from tensorflow.python.framework import ops
  from tensorflow.python.framework import tensor_spec
  from tensorflow.python.framework import type_spec
  from tensorflow.python.lib.core import _pywrap_py_func
  from tensorflow.python.ops import autograph_ops
  from tensorflow.python.ops import gen_script_ops
  from tensorflow.python.ops import resource_variable_ops
  from tensorflow.python.util import compat
  from tensorflow.python.util import deprecation
  from tensorflow.python.util import dispatch
  from tensorflow.python.util import nest
  from tensorflow.python.util import tf_inspect
  from tensorflow.python.util import variable_utils
  from tensorflow.python.util.tf_export import tf_export
label_desc: Use image node_id 3 for calling the EagerFunc obj's underlying member method code with example usage: obj._convert(value, dtype) and returns: ops, constant_op