code: def reinit_nested_vars(variables, indices=None):
    
    if isinstance(variables, (tuple, list)):
      return tf.group(*[
          reinit_nested_vars(variable, indices) for variable in variables])
    if indices is None:
      return variables.assign(tf.zeros_like(variables))
    else:
      zeros = tf.zeros([tf.shape(indices)[0]] + variables.shape[1:].as_list())
      return tf.scatter_update(variables, indices, zeros)
docs: Reset all variables in a nested tuple to zeros.
  
    Args:
      variables: Nested tuple or list of variables.
      indices: Batch indices to reset, defaults to all.
  
    Returns:
      Operation.