# Path: deep_architect/helpers/tensorflow_eager_support.py
# def set_is_training(outputs, is_training):
# 
#     def fn(mx):
#         if hasattr(mx, 'is_training'):
#             mx.is_training = is_training
# 
#     co.traverse_backward(outputs, fn)


import gc
import os
import tensorflow as tf
import numpy as np
import deep_architect.core as co
from builtins import object
from past.utils import old_div
from deep_architect.helpers.tensorflow_eager_support import set_is_training
        return loss

    def eval(self, inputs, outputs):
        results = {}
        if self.controller_mode:
            # Compute accuracy of model
            val_acc, loss = self._compute_accuracy(inputs, outputs,
                                                   self.val_dataset)
            results['validation_accuracy'] = val_acc

            # Log validation info
            self.controller_step += 1
            if self.log_output_to_terminal:  # and self.controller_step % self.display_step == 0:
                log_string = ""
                log_string += "ctrl_step={:<6d}".format(self.controller_step)
                log_string += " loss={:<7.3f}".format(loss)
                log_string += " acc={:<6.4f}".format(val_acc)
                print(log_string)

            # If controller phase finished, update epoch and switch back to
            # updating child params
            if self.controller_step % self.max_controller_steps == 0:
                self.controller_mode = False
                self.epoch += 1
                results['epoch'] = self.epoch
                print('Starting Image model mode')

        else:
            # Update child model parameters
            X_batch, y_batch = self.train_dataset.next_batch(self.batch_size)

# Path: deep_architect/helpers/tensorflow_eager_support.py
# def set_is_training(outputs, is_training):
# 
#     def fn(mx):
#         if hasattr(mx, 'is_training'):
#             mx.is_training = is_training
# 
#     co.traverse_backward(outputs, fn)


# Path: dev/enas/evaluator/enas_evaluator.py
import gc
import os
import tensorflow as tf
import numpy as np
import deep_architect.core as co
from builtins import object
from past.utils import old_div
from deep_architect.helpers.tensorflow_eager_support import set_is_training

        return loss

    def eval(self, inputs, outputs):
        results = {}
        if self.controller_mode:
            # Compute accuracy of model
            val_acc, loss = self._compute_accuracy(inputs, outputs,
                                                   self.val_dataset)
            results['validation_accuracy'] = val_acc

            # Log validation info
            self.controller_step += 1
            if self.log_output_to_terminal:  # and self.controller_step % self.display_step == 0:
                log_string = ""
                log_string += "ctrl_step={:<6d}".format(self.controller_step)
                log_string += " loss={:<7.3f}".format(loss)
                log_string += " acc={:<6.4f}".format(val_acc)
                print(log_string)

            # If controller phase finished, update epoch and switch back to
            # updating child params
            if self.controller_step % self.max_controller_steps == 0:
                self.controller_mode = False
                self.epoch += 1
                results['epoch'] = self.epoch
                print('Starting Image model mode')

        else:
            # Update child model parameters
            X_batch, y_batch = self.train_dataset.next_batch(self.batch_size)

            set_is_training(outputs, True)