Builds the TensorFlow variables of the migrated checkpoint.

  Args:
    checkpoint_reader: A `tf.train.NewCheckPointReader` of the checkpoint to
      be read from.
    name_value_fn: Function taking two arguments, `name` and `value`, which
      returns the pair of new name and value for that a variable of that name.

  Returns:
    Tuple of a dictionary with new variable names as keys and `tf.Variable`s as
    values, and a dictionary that maps the old variable names to the new
    variable names.

def _build_migrated_variables(checkpoint_reader, name_value_fn):
  """Builds the TensorFlow variables of the migrated checkpoint.

  Args:
    checkpoint_reader: A `tf.train.NewCheckPointReader` of the checkpoint to
      be read from.
    name_value_fn: Function taking two arguments, `name` and `value`, which
      returns the pair of new name and value for that a variable of that name.

  Returns:
    Tuple of a dictionary with new variable names as keys and `tf.Variable`s as
    values, and a dictionary that maps the old variable names to the new
    variable names.
  """

  names_to_shapes = checkpoint_reader.get_variable_to_shape_map()

  new_name_to_variable = {}
  name_to_new_name = {}

  for name in names_to_shapes:
    value = checkpoint_reader.get_tensor(name)
    new_name, new_value = name_value_fn(name, value)
    if new_name is None:
      continue

    name_to_new_name[name] = new_name
    new_name_to_variable[new_name] = tf.Variable(new_value)

  return new_name_to_variable, name_to_new_name