import tensorflow as tf

      logging.warn('The following variables in the checkpoint were not loaded:')
      for varname_not_loaded in not_loaded:
        logging.info('%s', varname_not_loaded)
  else:  # just get model vars.
    for v in model_vars:
      mapping[v.op.name] = v
  return mapping


def get_imagenet_vars_to_restore(imagenet_ckpt):
  """Returns dict of variables to restore from ImageNet-checkpoint."""
  vars_to_restore_imagenet = {}
  ckpt_var_names = tf.contrib.framework.list_variables(imagenet_ckpt)
  ckpt_var_names = [name for (name, unused_shape) in ckpt_var_names]
  model_vars = tf.global_variables()
  for v in model_vars:
    if 'global_step' in v.op.name: continue
    mvname_noprefix = v.op.name.replace('depth_prediction/', '')
    mvname_noprefix = mvname_noprefix.replace('moving_mean', 'mu')
    mvname_noprefix = mvname_noprefix.replace('moving_variance', 'sigma')
    if mvname_noprefix in ckpt_var_names:
      vars_to_restore_imagenet[mvname_noprefix] = v
    else:
      logging.info('The following variable will not be restored from '
