def assign_nested_vars(variables, tensors, indices=None):
  """Assign tensors to matching nested tuple of variables.

  Args:
    variables: Nested tuple or list of variables to update.
    tensors: Nested tuple or list of tensors to assign.
    indices: Batch indices to assign to; default to all.

  Returns:
    Operation.
  """
  if isinstance(variables, (tuple, list)):
    return tf.group(*[
        assign_nested_vars(variable, tensor)
        for variable, tensor in zip(variables, tensors)])
  if indices is None:
    return variables.assign(tensors)
  else:
    return tf.scatter_update(variables, indices, tensors)
def assign_nested_vars ( variables , tensors , indices = None ) : if isinstance ( variables , ( tuple , list ) ) : return tf . group ( * [ assign_nested_vars ( variable , tensor ) for variable , tensor in zip ( variables , tensors ) ] ) if indices is None : return variables . assign ( tensors ) else : return tf . scatter_update ( variables , indices , tensors )
Assign tensors to matching nested tuple of variables.

  Args:
    variables: Nested tuple or list of variables to update.
    tensors: Nested tuple or list of tensors to assign.
    indices: Batch indices to assign to; default to all.

  Returns:
    Operation.