class_docstr: A context to maintain collection change in a tower.
class_docstr_tok: ["A","context","to","maintain","collection","change","in","a","tower","."]
docstr: Args:
     name (str): name of the tower
     check_diff (bool): whether to check and print about collection change
          when leaving this guard.
     freeze_keys (list): list of keys to backup when entering and restore when leaving this guard.
     diff_whitelist (list): list of keys to ignore, when check_diff is True.
          Defaults to some collections that are normally changed,
          including variables, losses, contexts, queue runners.
docstr_tok: ["Args",":","name","(","str",")",":","name","of","the","tower","check_diff","(","bool",")",":","whether","to","check","and","print","about","collection","change","when","leaving","this","guard",".","freeze_keys","(","list",")",":","list","of","keys","to","backup","when","entering","and","restore","when","leaving","this","guard",".","diff_whitelist","(","list",")",":","list","of","keys","to","ignore",",","when","check_diff","is","True",".","Defaults","to","some","collections","that","are","normally","changed",",","including","variables",",","losses",",","contexts",",","queue","runners","."]
code: def __init__(
      self, name, check_diff, freeze_keys=(), diff_whitelist=None
  ):
      """
      Args:
         name (str): name of the tower
         check_diff (bool): whether to check and print about collection change
              when leaving this guard.
         freeze_keys (list): list of keys to backup when entering and restore when leaving this guard.
         diff_whitelist (list): list of keys to ignore, when check_diff is True.
              Defaults to some collections that are normally changed,
              including variables, losses, contexts, queue runners.
      """
      self._name = name
      self._check_diff = check_diff
      if diff_whitelist is None:
          diff_whitelist = CollectionGuard._default_diff_whitelist()
      self._whitelist = set(diff_whitelist)
      self._freeze_keys = freeze_keys
      self._inverse_graphkeys = get_inverse_graphkeys()
  
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 to create a new CollectionGuard object from inherited base classes: object with example: obj = CollectionGuard(name, check_diff, freeze_keys, diff_whitelist)