class_docstr: Interface for weight compression algorithm that acts on a per-layer basis.
  
  This allows both options of either decompressing during inference or
  decompressing prior to inference (where compression occurs by applying a
  tool such as zip to the model file).
  
  This interface is a purely functional one.
class_docstr_tok: ["Interface","for","weight","compression","algorithm","that","acts","on","a","per-layer","basis",".","This","allows","both","options","of","either","decompressing","during","inference","or","decompressing","prior","to","inference","(","where","compression","occurs","by","applying","a","tool","such","as","zip","to","the","model","file",")",".","This","interface","is","a","purely","functional","one","."]
docstr: Add training weight assign op to the model update list.
  
   This method is for the case that training weight should update to a
  specific value not from the model optimizer. It will throw an error if it
  can't find the training weight.
  
   This method should called in project_training_weights. During the training,
  We collect all update_training_weight calls and make an UpdateOp for each
  call. Finally, we put all these update ops to model.add_update.
  
  Args:
    training_weight: tf.Tensor representing a training weight.
    value: tf.Tensor representing a value to be assigned to the training
      weight.
  Raises:
    ValueError if it can't find the training weight.
docstr_tok: ["Add","training","weight","assign","op","to","the","model","update","list",".","This","method","is","for","the","case","that","training","weight","should","update","to","a","specific","value","not","from","the","model","optimizer",".","It","will","throw","an","error","if","it","ca","n't","find","the","training","weight",".","This","method","should","called","in","project_training_weights",".","During","the","training",",","We","collect","all","update_training_weight","calls","and","make","an","UpdateOp","for","each","call",".","Finally",",","we","put","all","these","update","ops","to","model.add_update",".","Args",":","training_weight",":","tf.Tensor","representing","a","training","weight",".","value",":","tf.Tensor","representing","a","value","to","be","assigned","to","the","training","weight",".","Raises",":","ValueError","if","it","ca","n't","find","the","training","weight","."]
code: def update_training_weight(
      self, training_weight: tf.Tensor, value: tf.Tensor
  ):
      """Add training weight assign op to the model update list.
  
       This method is for the case that training weight should update to a
      specific value not from the model optimizer. It will throw an error if it
      can't find the training weight.
  
       This method should called in project_training_weights. During the training,
      We collect all update_training_weight calls and make an UpdateOp for each
      call. Finally, we put all these update ops to model.add_update.
  
      Args:
        training_weight: tf.Tensor representing a training weight.
        value: tf.Tensor representing a value to be assigned to the training
          weight.
      Raises:
        ValueError if it can't find the training weight.
      """
      for tensor, weight in self.tensor_weight_pairs:
          if training_weight is tensor:
              self.update_ops.append(weight.assign(value))
              return
  
      raise ValueError(
          "Training weight not found. Please call "
          "the update_training_weight with given training "
          "weight tensor."
      )
  
file_path: model-optimization/tensorflow_model_optimization/python/core/common/keras/compression/algorithm.py
imports: import abc
  from typing import List, Any
  import dataclasses
  import tensorflow
  from tensorflow_model_optimization.python.core.common.keras.compression.internal import optimize
label_desc: Use image node_id 6 for calling the WeightCompressor obj's underlying member method code with example usage: obj.update_training_weight(training_weight, value) without return types