def _map_to_inference_weights(training_weights, algorithm, training_tensors):
  """Construct the inference weight values from the weights after training.

    The weight values have the same structure as the output of
    `tf.keras.layers.Layer.get_weights`.

  Args:
    training_weights: layer's weights from training, retrieved via
      layer.get_weights()
    algorithm: weight compression algorithm
    training_tensors: map from compressible weight attribute (e.g. 'kernel') to
      relevant tensors.

  Returns:
    Initial weight values for training.

  Example:
    training_weights =    [kernel_var1, kernel_var2, bias]
    training_tensors = {'kernel': [kernel_var1, kernel_var2]}
    expected output:   [compress([kernel_var1, kernel_var2]), bias]
  """

  compressed_weights = []
  weights = ['kernel', 'bias']
  layer_weights_i = 0
  for weight in weights:
    if weight in training_tensors:
      compressed = algorithm.compress(*training_tensors[weight])
      for c in compressed:
        compressed_weights.append(c.numpy())
      layer_weights_i += len(training_tensors[weight])
    else:
      compressed_weights.append(training_weights[layer_weights_i])
      layer_weights_i += 1
  return compressed_weights