original_docstring: Finds PolymorphicFunctions attached to objects and saves them.
docstring: Finds PolymorphicFunctions attached to objects and saves them.
docstring_tokens: Finds PolymorphicFunctions attached to objects and saves them .
code: def add_polymorphic_functions_to_object_graph_proto(
      checkpointable_objects, saved_object_graph):
    """Finds PolymorphicFunctions attached to objects and saves them."""
    existing_objects = list(zip(checkpointable_objects, saved_object_graph.nodes))
    for obj, obj_proto in existing_objects:
      for attribute_name in dir(obj):
        try:
          attribute_value = getattr(obj, attribute_name, None)
        except:  # pylint: disable=bare-except
          # We really don't want to throw an exception just because some object's
          # attribute accessor is broken.
          attribute_value = None
        # TODO(allenl): Consider de-duplicating functions which are referenced
        # from multiple attributes.
        if isinstance(attribute_value, def_function.PolymorphicFunction):
          function_node_id = len(saved_object_graph.nodes)
          function_node = saved_object_graph.nodes.add()
          function_node.function.CopyFrom(
              _serialize_polymorphic_function(attribute_value))
          reference = obj_proto.children.add()
          reference.node_id = function_node_id
          reference.local_name = attribute_name
code_tokens: def add_polymorphic_functions_to_object_graph_proto ( checkpointable_objects , saved_object_graph ) : existing_objects = list ( zip ( checkpointable_objects , saved_object_graph . nodes ) ) for obj , obj_proto in existing_objects : for attribute_name in dir ( obj ) : try : attribute_value = getattr ( obj , attribute_name , None ) except : attribute_value = None if isinstance ( attribute_value , def_function . PolymorphicFunction ) : function_node_id = len ( saved_object_graph . nodes ) function_node = saved_object_graph . nodes . add ( ) function_node . function . CopyFrom ( _serialize_polymorphic_function ( attribute_value ) ) reference = obj_proto . children . add ( ) reference . node_id = function_node_id reference . local_name = attribute_name
short_docstring: Finds PolymorphicFunctions attached to objects and saves them.
short_docstring_tokens: Finds PolymorphicFunctions attached to objects and saves them .
comment: """Finds PolymorphicFunctions attached to objects and saves them."""$SEP$# pylint: disable=bare-except$SEP$# We really don't want to throw an exception just because some object's$SEP$# attribute accessor is broken.$SEP$# TODO(allenl): Consider de-duplicating functions which are referenced$SEP$# from multiple attributes.