def get_moving_average_variables_to_restore(global_step=None):
  """Gets variables to restore.

  Args:
    global_step: A tensor of global step to include. If None, do not restore
      global step variable, which is for exporting inference graph. For only
      evaluation, specifying a global step is needed.

  Returns:
    variables_to_restore: A dictionary of variables to restore.
  """
  variable_averages = tf.train.ExponentialMovingAverage(0.0, global_step)
  variables_to_restore = variable_averages.variables_to_restore()

  if global_step is not None:
    variables_to_restore[global_step.op.name] = global_step

  return variables_to_restore