docs: def _pre_train(self,
                     stop_param_updates,
                     num_epochs,
                     updates_epoch):
          """Set parameters and constants before training."""
          # Calculate the total number of updates given early stopping.
          updates = {k: stop_param_updates.get(k, num_epochs) * updates_epoch
                     for k, v in self.params.items()}
  
          # Calculate the value of a single step given the number of allowed
          # updates.
          single_steps = {k: np.exp(-((1.0 - (1.0 / v)))
                          * self.params[k]['factor'])
                          for k, v in updates.items()}
  
          # Calculate the factor given the true factor and the value of a
          # single step.
          constants = {k: np.exp(-self.params[k]['factor']) / v
                       for k, v in single_steps.items()}
  
          return constants