import tensorflow as tf

            index (int): index of this tower, only used in training.
            vs_name (str): Open a new variable scope with this name.
        """
        self._name = tower_name
        self._is_training = bool(is_training)

        if not self._is_training:
            assert index == 0, \
                "TowerContext(index) is only valid in training!"

        self._index = int(index)
        self._vs_name = vs_name
        if len(vs_name):
            assert len(tower_name), "TowerContext(vs_name) cannot be used with an empty tower_name!"

        self._initial_vs_reuse = tf.get_variable_scope().reuse
        if self.has_own_variables:
            assert not self._initial_vs_reuse, \
                "Cannot create tower {} with reuse=True!".format(tower_name)

        self._collection_guard = CollectionGuard(
            self._name,
            check_diff=not self.is_main_training_tower,
            freeze_keys=self._keys_to_freeze())

    @property
    def is_main_training_tower(self):
        return self.is_training and self._index == 0

    @property
