code: def TowerContext(tower_name, is_training, vs_name=""):
      """
      The context for a tower function, containing metadata about the current tower.
      Tensorpack trainers use :class:`TowerContext` to manage tower function.
      Many tensorpack layers have to be called under a :class:`TowerContext`.
  
      Example:
  
      .. code-block:: python
  
          with TowerContext('', is_training=True):
              # call a tensorpack layer or a tower function
      """
      if is_training:
          return TrainTowerContext(tower_name, vs_name=vs_name)
      else:
          return PredictTowerContext(tower_name, vs_name=vs_name)
  
imports: from abc import ABCMeta, abstractmethod, abstractproperty
  import six
  from ..compat import tfv1
  from ..utils import logger
  from ..utils.argtools import call_only_once
  from ..utils.develop import HIDE_DOC
  from ..utils.naming import MOVING_SUMMARY_OPS_KEY
  from .collection import CollectionGuard
  from .common import get_op_or_tensor_by_name, get_op_tensor_name
label_desc: Use image node_id 2 for calling a global function with example usage: TowerContext(tower_name, is_training, vs_name) and returns: TrainTowerContext, PredictTowerContext