def _compute_tolerance(workers):
  """Computes how many workers can be ignored for one gradient update.

  These numbers were chosen based on just a few expriments.  They are rather
  arbitrary, feel free to change them.

  Args:
    workers: Number of workers used during computations.

  Returns:
    int: how many workers can be preemptied during one step.
  """
  if workers <= 4:
    return 0
  elif workers <= 10:
    return 1
  elif workers <= 30:
    return int(0.1 * workers)
  else:
    return int(0.5 * workers)