import tensorflow as tf

def train(loss, global_step):
  """Train eccentricity model.

  Create an optimizer and apply to all trainable variables. 

  Args:
    total_loss: Total loss from loss().
    global_step: Integer Variable counting the number of training steps
      processed.
  Returns:
    train_op: op for training.
  """
   # Compute gradients.

  tf.scalar_summary(loss.op.name, loss)

  optimizer = tf.train.AdagradOptimizer(FLAGS.learning_rate)
  # Use the optimizer to apply the gradients that minimize the loss
  # (and also increment the global step counter) as a single training step.
  train_op = optimizer.minimize(loss, global_step=global_step)
  return train_op

  return train_op
