parameters: (self, name, graph, inputs, outputs, attrs)
docstring: Initializes an eager defined function.
  
      Args:
        name: str, the name for the created function.
        graph: Graph, the graph containing the operations in the function
        inputs: the tensors in the graph to be used as inputs to the function
        outputs: the tensors in the graph which will be outputs from the function
        attrs: dict mapping names of attributes to their AttrValue values
docstring_summary: Initializes an eager defined function.
docstring_tokens: Initializes an eager defined function .
function: def __init__(self, name, graph, inputs, outputs, attrs):
      """Initializes an eager defined function.
  
      Args:
        name: str, the name for the created function.
        graph: Graph, the graph containing the operations in the function
        inputs: the tensors in the graph to be used as inputs to the function
        outputs: the tensors in the graph which will be outputs from the function
        attrs: dict mapping names of attributes to their AttrValue values
      """
      for function_callback in _function_callbacks:
        function_callback(self, name, graph, tuple(inputs), tuple(outputs))
  
      input_ops = set(arg.op for arg in inputs)
      operations = [op for op in graph.get_operations() if op not in input_ops]
  
      graph_output_names = graph._output_names  # pylint: disable=protected-access
      if (graph_output_names is not None and
          all(ops.tensor_id(t) in graph_output_names for t in outputs)):
        output_names = [
            compat.as_bytes(graph_output_names[ops.tensor_id(t)]) for t in outputs
        ]
        if len(set(output_names)) != len(output_names):
          # There are duplicate names for some reason, probably an invalid
          # signature. Revert to auto-naming.
          output_names = []
      else:
        output_names = []
      fn = pywrap_tf_session.TF_GraphToFunction_wrapper(
          graph._c_graph,  # pylint: disable=protected-access
          compat.as_str(name),
          False,
          [o._c_op for o in operations],  # pylint: disable=protected-access
          [t._as_tf_output() for t in inputs],  # pylint: disable=protected-access
          [t._as_tf_output() for t in outputs],  # pylint: disable=protected-access
          output_names,
          [o._c_op for o in graph.control_outputs],  # pylint: disable=protected-access
          [],  # control_output_names
          None,
          compat.as_str(""))
  
      for name, attr_value in attrs.items():
        serialized = attr_value.SerializeToString()
        # TODO(iga): this creates and deletes a new TF_Status for every attr.
        # It might be worth creating a convenient way to re-use status.
        pywrap_tf_session.TF_FunctionSetAttrValueProto(fn, compat.as_str(name),
                                                       serialized)
  
      # TODO(apassos) avoid creating a FunctionDef (specially to grab the
      # signature, but also in general it's nice not to depend on it.
      with c_api_util.tf_buffer() as buffer_:
        pywrap_tf_session.TF_FunctionToFunctionDef(fn, buffer_)
        proto_data = pywrap_tf_session.TF_GetBuffer(buffer_)
      function_def = function_pb2.FunctionDef()
      function_def.ParseFromString(compat.as_bytes(proto_data))
      self._name = compat.as_bytes(function_def.signature.name)
      with ops.init_scope():
        if context.executing_eagerly():
          context.ensure_initialized()
          context.add_function(fn)
          self._function_deleter = _EagerDefinedFunctionDeleter(self.name)
          self._registered_on_context = True
      self.definition = function_def
      self.signature = function_def.signature
      self._num_outputs = len(self.signature.output_arg)
      self._output_types = [o.type for o in self.signature.output_arg]
      self._output_shapes = [o.shape for o in outputs]
      self._control_captures = graph.control_captures
      # Shallow copy outputs since ConcreteFunction may mutate it.
      self._func_graph_outputs = list(outputs)
      self.grad_func_name = None
      self.python_grad_func = None
      self._c_func = c_api_util.ScopedTFFunction(fn)
      self._grad_func = None
      self.graph = graph
      self._stateful_ops = tuple(op for op in operations if op._is_stateful)
function_tokens: def __init__ ( self , name , graph , inputs , outputs , attrs ) : for function_callback in _function_callbacks : function_callback ( self , name , graph , tuple ( inputs ) , tuple ( outputs ) ) input_ops = set ( arg . op for arg in inputs ) operations = [ op for op in graph . get_operations ( ) if op not in input_ops ] graph_output_names = graph . _output_names # pylint: disable=protected-access if ( graph_output_names is not None and all ( ops . tensor_id ( t ) in graph_output_names for t in outputs ) ) : output_names = [ compat . as_bytes ( graph_output_names [ ops . tensor_id ( t ) ] ) for t in outputs ] if len ( set ( output_names ) ) != len ( output_names ) : # There are duplicate names for some reason, probably an invalid # signature. Revert to auto-naming. output_names = [ ] else : output_names = [ ] fn = pywrap_tf_session . TF_GraphToFunction_wrapper ( graph . _c_graph , # pylint: disable=protected-access compat . as_str ( name ) , False , [ o . _c_op for o in operations ] , # pylint: disable=protected-access [ t . _as_tf_output ( ) for t in inputs ] , # pylint: disable=protected-access [ t . _as_tf_output ( ) for t in outputs ] , # pylint: disable=protected-access output_names , [ o . _c_op for o in graph . control_outputs ] , # pylint: disable=protected-access [ ] , # control_output_names None , compat . as_str ( "" ) ) for name , attr_value in attrs . items ( ) : serialized = attr_value . SerializeToString ( ) # TODO(iga): this creates and deletes a new TF_Status for every attr. # It might be worth creating a convenient way to re-use status. pywrap_tf_session . TF_FunctionSetAttrValueProto ( fn , compat . as_str ( name ) , serialized ) # TODO(apassos) avoid creating a FunctionDef (specially to grab the # signature, but also in general it's nice not to depend on it. with c_api_util . tf_buffer ( ) as buffer_ : pywrap_tf_session . TF_FunctionToFunctionDef ( fn , buffer_ ) proto_data = pywrap_tf_session . TF_GetBuffer ( buffer_ ) function_def = function_pb2 . FunctionDef ( ) function_def . ParseFromString ( compat . as_bytes ( proto_data ) ) self . _name = compat . as_bytes ( function_def . signature . name ) with ops . init_scope ( ) : if context . executing_eagerly ( ) : context . ensure_initialized ( ) context . add_function ( fn ) self . _function_deleter = _EagerDefinedFunctionDeleter ( self . name ) self . _registered_on_context = True self . definition = function_def self . signature = function_def . signature self . _num_outputs = len ( self . signature . output_arg ) self . _output_types = [ o . type for o in self . signature . output_arg ] self . _output_shapes = [ o . shape for o in outputs ] self . _control_captures = graph . control_captures # Shallow copy outputs since ConcreteFunction may mutate it. self . _func_graph_outputs = list ( outputs ) self . grad_func_name = None self . python_grad_func = None self . _c_func = c_api_util . ScopedTFFunction ( fn ) self . _grad_func = None self . graph = graph self . _stateful_ops = tuple ( op for op in operations if op . _is_stateful )