def switch_training(self, flag):
        """
        Switch training mode.
        :param flag: switch on training mode when flag is True.
        """
        if self._is_training == flag: return
        self._is_training = flag
        if flag:
            self._training_flag.set_value(1)
        else:
            self._training_flag.set_value(0)