# Path: settings.py
# FLAGS = flags.FLAGS
# 
# Path: utils/helpers.py
# def get_iter_from_pretrained_model(checkpoint_file_name):
#   ''' extracts the iterator count of a dumped checkpoint from the checkpoint file name
#   :param checkpoint_file_name: name of checkpoint file - must contain a
#   :return: iterator number
#   '''
#   file_basename = os.path.basename(checkpoint_file_name)
#   assert re.compile('[A-Za-z0-9]+[-][0-9]+').match(file_basename)
#   idx = re.findall(r'-\b\d+\b', file_basename)[0][1:]
#   return int(idx)
# 
# def remove_items_from_dict(string_dict, strings_to_remove):
#   result_dict = {}
#   for v_name, v in string_dict.items():
#     if not any([(s in v_name) for s in strings_to_remove]):
#       result_dict[v_name] = v
#   return result_dict


import tensorflow as tf
from settings import FLAGS
from utils.helpers import get_iter_from_pretrained_model, remove_items_from_dict
    self.status = True

    init_op = tf.group(tf.global_variables_initializer(), tf.local_variables_initializer())

    self.sess = tf.Session()
    self.sess.run(init_op)

    # Start input enqueue threads
    self.coord = tf.train.Coordinator()
    self.threads = tf.train.start_queue_runners(sess=self.sess, coord=self.coord)

  def stop_session(self):
    """Stops a current session."""
    if self.sess and self.coord:
      self.coord.join(self.threads)
      self.sess.close()
      self.status = False

  def start_saver(self):
    """Constructs a saver and if pretrained model given, loads the model."""
    print('Constructing saver')
    self.saver = tf.train.Saver(max_to_keep=0)

    # restore dumped model if provided
    if FLAGS.pretrained_model:
      print('Restore model from: ' + str(FLAGS.pretrained_model))
      latest_checkpoint = tf.train.latest_checkpoint(FLAGS.pretrained_model)
      self.itr_start = get_iter_from_pretrained_model(latest_checkpoint) + 1
      print('Start with iteration: ' + str(self.itr_start))


# Path: settings.py
# FLAGS = flags.FLAGS
# 
# Path: utils/helpers.py
# def get_iter_from_pretrained_model(checkpoint_file_name):
#   ''' extracts the iterator count of a dumped checkpoint from the checkpoint file name
#   :param checkpoint_file_name: name of checkpoint file - must contain a
#   :return: iterator number
#   '''
#   file_basename = os.path.basename(checkpoint_file_name)
#   assert re.compile('[A-Za-z0-9]+[-][0-9]+').match(file_basename)
#   idx = re.findall(r'-\b\d+\b', file_basename)[0][1:]
#   return int(idx)
# 
# def remove_items_from_dict(string_dict, strings_to_remove):
#   result_dict = {}
#   for v_name, v in string_dict.items():
#     if not any([(s in v_name) for s in strings_to_remove]):
#       result_dict[v_name] = v
#   return result_dict


# Path: core/Initializer.py
import tensorflow as tf
from settings import FLAGS
from utils.helpers import get_iter_from_pretrained_model, remove_items_from_dict

    self.status = True

    init_op = tf.group(tf.global_variables_initializer(), tf.local_variables_initializer())

    self.sess = tf.Session()
    self.sess.run(init_op)

    # Start input enqueue threads
    self.coord = tf.train.Coordinator()
    self.threads = tf.train.start_queue_runners(sess=self.sess, coord=self.coord)

  def stop_session(self):
    """Stops a current session."""
    if self.sess and self.coord:
      self.coord.join(self.threads)
      self.sess.close()
      self.status = False

  def start_saver(self):
    """Constructs a saver and if pretrained model given, loads the model."""
    print('Constructing saver')
    self.saver = tf.train.Saver(max_to_keep=0)

    # restore dumped model if provided
    if FLAGS.pretrained_model:
      print('Restore model from: ' + str(FLAGS.pretrained_model))
      latest_checkpoint = tf.train.latest_checkpoint(FLAGS.pretrained_model)
      self.itr_start = get_iter_from_pretrained_model(latest_checkpoint) + 1
      print('Start with iteration: ' + str(self.itr_start))


      if FLAGS.exclude_from_restoring is not None: