class_docstr: A context to maintain collection change in a tower.
class_docstr_tok: ["A","context","to","maintain","collection","change","in","a","tower","."]
code: def _print_diff(self, new):
      newly_created = []
      size_change = []
      for k, v in six.iteritems(new):
          if k in self._whitelist or k in self._freeze_keys:
              continue
          if k not in self.original:
              newly_created.append((self._key_name(k), len(v)))
          else:
              old_v = self.original[k]
              if len(old_v) != len(v):
                  size_change.append(
                      (self._key_name(k), len(old_v), len(v))
                  )
      if newly_created:
          logger.info(
              "New collections created in tower {}: ".format(self._name)
              + ", ".join(
                  [
                      "{} of size {}".format(key, size)
                      for key, size in newly_created
                  ]
              )
          )
      if size_change:
          logger.info(
              "Size of these collections were changed in {}: {}".format(
                  self._name,
                  ", ".join(
                      "({}: {}->{})".format(*t) for t in size_change
                  ),
              )
          )
  
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 6 for calling the CollectionGuard obj's underlying member method code with example usage: obj._print_diff(new) without return types