def _at_step_1_and_every_nth_step(period):
  """A function that's true at 1 and n when n % period == 0."""
  if period is None:
    return lambda step_n: False

  def _at_1_and_periodically(step_n):
    return (step_n == 1) or (step_n > 0 and (step_n % period == 0))
  return _at_1_and_periodically
A function that's true at 1 and n when n % period == 0.
trax/supervised/training.py