code: def backup_collection(keys=None):
      """
      Args:
          keys (list): list of collection keys to backup.
              Defaults to all keys in the graph.
  
      Returns:
          dict: the backup
      """
      if keys is None:
          keys = tf.get_default_graph().get_all_collection_keys()
      ret = {}
      assert isinstance(keys, (list, tuple, set))
      for k in keys:
          ret[k] = copy(tf.get_collection(k))
      return ret
  
file_path: tensorpack/tensorpack/tfutils/collection.py
imports: from contextlib import contextmanager
  from copy import copy
  import six
  from ..compat import tfv1
  from ..utils import logger
  from ..utils.argtools import memoized
label_desc: Use image node_id 1 for calling a global function with example usage: backup_collection(keys) and returns: ret