def mode_batch_size(mode, hparams):
  """Returns the batch size for a given mode (train or eval).

  Args:
    mode: Either 'train' or 'eval'.
    hparams: Hyperparameters.

  Returns:
    Integer batch size.

  Raises:
    ValueError: If mode is not 'train' or 'eval'.
  """
  if mode == 'train':
    return hparams.batch_size
  elif mode == 'eval':
    return hparams.eval_batch_size
  else:
    raise ValueError('Invalid --mode=%r' % mode)