class_docstr: Defines how to apply a faster version of the EPR algorithm.
class_docstr_tok: ["Defines","how","to","apply","a","faster","version","of","the","EPR","algorithm","."]
code: def compress_training_weights(
      self, *training_weights: tf.Tensor
  ) -> List[tf.Tensor]:
      if len(training_weights) == 2:
          # Bias or dense kernel.
          weight, log_step = training_weights
          weight_shape = tf.shape(weight)
      else:
          # Convolution kernel.
          weight, weight_shape, log_step = training_weights
      em = tfc.PowerLawEntropyModel(
          coding_rank=weight.shape.rank, alpha=self.alpha
      )
      string = em.compress(weight / tf.exp(log_step))
      weight_shape = tf.cast(weight_shape, tf.uint16)
      log_step = tf.cast(log_step, tf.float16)
      return [string, weight_shape, log_step]
  
imports: import functools
  from typing import Callable, List, Tuple
  import tensorflow
  import tensorflow_compression
  from tensorflow_model_optimization.python.core.common.keras.compression import algorithm
label_desc: Use image node_id 4 for calling the FastEPR obj's underlying member method code with example usage: obj.compress_training_weights() and returns: list