parameters: (self, trackable)
docstring: Set a checkpoint<->object correspondence and process slot variables.
  
      Args:
        trackable: The object to record a correspondence for.
  
      Returns:
        True if this is a new assignment, False if this object has already been
        mapped to a checkpointed `Object` proto.
      Raises:
        AssertionError: If another object is already bound to the `Object` proto.
docstring_summary: Set a checkpoint<->object correspondence and process slot variables.
docstring_tokens: Set a checkpoint< - > object correspondence and process slot variables .
function: def bind_object(self, trackable):
      """Set a checkpoint<->object correspondence and process slot variables.
  
      Args:
        trackable: The object to record a correspondence for.
  
      Returns:
        True if this is a new assignment, False if this object has already been
        mapped to a checkpointed `Object` proto.
      Raises:
        AssertionError: If another object is already bound to the `Object` proto.
      """
      checkpoint = self.checkpoint
      checkpoint.all_python_objects.add(trackable)
      current_assignment = checkpoint.object_by_proto_id.get(self._proto_id, None)
      checkpoint.matched_proto_ids.add(self._proto_id)
      if current_assignment is None:
        checkpoint.object_by_proto_id[self._proto_id] = trackable
        for deferred_slot_restoration in (
            checkpoint.deferred_slot_restorations.pop(self._proto_id, ())):
          self._queue_slot_variable_for_restoration(
              trackable, deferred_slot_restoration.original_variable,
              deferred_slot_restoration.slot_variable_id,
              deferred_slot_restoration.slot_name)
        for slot_restoration in checkpoint.slot_restorations.pop(
            self._proto_id, ()):
          optimizer_object = checkpoint.object_by_proto_id.get(
              slot_restoration.optimizer_id, None)
          if optimizer_object is None:
            # The optimizer has not yet been created or tracked. Record in the
            # checkpoint that the slot variables need to be restored when it is.
            checkpoint.deferred_slot_restorations.setdefault(
                slot_restoration.optimizer_id, []).append(
                    _DeferredSlotVariableRestoration(
                        original_variable=trackable,
                        slot_variable_id=slot_restoration.slot_variable_id,
                        slot_name=slot_restoration.slot_name))
  
          # `optimizer_object` can be a `Checkpoint` when user only needs the
          # attributes the optimizer holds, such as `iterations`. In those cases,
          # it would not have the optimizer's `_create_or_restore_slot_variable`
          # method.
          elif hasattr(optimizer_object, "_create_or_restore_slot_variable"):
            self._queue_slot_variable_for_restoration(
                optimizer_object, trackable, slot_restoration.slot_variable_id,
                slot_restoration.slot_name)
        return True  # New assignment
      else:
        # The object was already mapped for this checkpoint load, which means
        # we don't need to do anything besides check that the mapping is
        # consistent (if the dependency DAG is not a tree then there are
        # multiple paths to the same object).
        if current_assignment is not trackable:
          logging.warning(
              "Inconsistent references when loading the checkpoint into this "
              "object graph. For example, in the saved checkpoint object, "
              "`model.layer.weight` and `model.layer_copy.weight` reference the "
              "same variable, while in the current object these are two different"
              " variables. The referenced variables are:"
              f"({current_assignment} and {trackable}).")
        return False
function_tokens: def bind_object ( self , trackable ) : checkpoint = self . checkpoint checkpoint . all_python_objects . add ( trackable ) current_assignment = checkpoint . object_by_proto_id . get ( self . _proto_id , None ) checkpoint . matched_proto_ids . add ( self . _proto_id ) if current_assignment is None : checkpoint . object_by_proto_id [ self . _proto_id ] = trackable for deferred_slot_restoration in ( checkpoint . deferred_slot_restorations . pop ( self . _proto_id , ( ) ) ) : self . _queue_slot_variable_for_restoration ( trackable , deferred_slot_restoration . original_variable , deferred_slot_restoration . slot_variable_id , deferred_slot_restoration . slot_name ) for slot_restoration in checkpoint . slot_restorations . pop ( self . _proto_id , ( ) ) : optimizer_object = checkpoint . object_by_proto_id . get ( slot_restoration . optimizer_id , None ) if optimizer_object is None : # The optimizer has not yet been created or tracked. Record in the # checkpoint that the slot variables need to be restored when it is. checkpoint . deferred_slot_restorations . setdefault ( slot_restoration . optimizer_id , [ ] ) . append ( _DeferredSlotVariableRestoration ( original_variable = trackable , slot_variable_id = slot_restoration . slot_variable_id , slot_name = slot_restoration . slot_name ) ) # `optimizer_object` can be a `Checkpoint` when user only needs the # attributes the optimizer holds, such as `iterations`. In those cases, # it would not have the optimizer's `_create_or_restore_slot_variable` # method. elif hasattr ( optimizer_object , "_create_or_restore_slot_variable" ) : self . _queue_slot_variable_for_restoration ( optimizer_object , trackable , slot_restoration . slot_variable_id , slot_restoration . slot_name ) return True # New assignment else : # The object was already mapped for this checkpoint load, which means # we don't need to do anything besides check that the mapping is # consistent (if the dependency DAG is not a tree then there are # multiple paths to the same object). if current_assignment is not trackable : logging . warning ( "Inconsistent references when loading the checkpoint into this " "object graph. For example, in the saved checkpoint object, " "`model.layer.weight` and `model.layer_copy.weight` reference the " "same variable, while in the current object these are two different" " variables. The referenced variables are:" f"({current_assignment} and {trackable})." ) return False