(variable_mapping)
Assign variables according to the provided `variable_mapping`.

  Args:
    variable_mapping: An iterable of variable pairs, each corresponding to a
      variable whose value is to be overwitten (destination) and a reference
      variable (source).

  Returns:
    If running in TensorFlow Eager mode, returns None; otherwise, returns a list
    of assignment operations.
Assign variables according to the provided `variable_mapping`.
Assign variables according to the provided variable_mapping .
def assign_variables(variable_mapping):
  """Assign variables according to the provided `variable_mapping`.

  Args:
    variable_mapping: An iterable of variable pairs, each corresponding to a
      variable whose value is to be overwitten (destination) and a reference
      variable (source).

  Returns:
    If running in TensorFlow Eager mode, returns None; otherwise, returns a list
    of assignment operations.
  """
  for variable, reference_variable in variable_mapping:
    if tf.executing_eagerly():
      # Just perform the assignment.
      variable.assign(reference_variable)
    else:
      # Piggyback on the variable's initializer attribute, which is included in
      # `tf.global_variables_initializer`.
      initializer_ops = [variable._initializer_op]  # pylint: disable=protected-access
      if isinstance(reference_variable, tf.Variable):
        initializer_ops += [reference_variable._initializer_op]  # pylint: disable=protected-access
      with tf.control_dependencies(initializer_ops):
        assign_op = variable.assign(reference_variable)
      variable._initializer_op = assign_op
def assign_variables ( variable_mapping ) : for variable , reference_variable in variable_mapping : if tf . executing_eagerly ( ) : # Just perform the assignment. variable . assign ( reference_variable ) else : # Piggyback on the variable's initializer attribute, which is included in # `tf.global_variables_initializer`. initializer_ops = [ variable . _initializer_op ] # pylint: disable=protected-access if isinstance ( reference_variable , tf . Variable ) : initializer_ops += [ reference_variable . _initializer_op ] # pylint: disable=protected-access with tf . control_dependencies ( initializer_ops ) : assign_op = variable . assign ( reference_variable ) variable . _initializer_op = assign_op