code: def train(self, params, epoch):
      
  
      # Callback used to log information on every batch
      def log(model, batch_idx):
        if batch_idx % params["log_interval"] == 0:
          entropy = model.entropy()
          print("logging: {} learning iterations, entropy: {} / {}".format(
            model.getLearningIterations(), float(entropy), model.maxEntropy()))
  
          if params["create_plots"]:
            plotDutyCycles(model.dutyCycle,
                           self.resultsDir + "/figure_" + str(epoch) + "_" +
                           str(model.getLearningIterations()))
  
  
      # Adjust first epoch batch size to stabilize the dutycycles at the
      # beginning of the training
      loader = self.train_loader
      batches_in_epoch = params["batches_in_epoch"]
      if "first_epoch_batch_size" in params:
        if epoch == 0:
          batches_in_epoch = params.get("batches_in_first_epoch", batches_in_epoch)
          loader = torch.utils.data.DataLoader(self.train_loader.dataset,
                                               batch_size=params["first_epoch_batch_size"],
                                               sampler=self.train_loader.sampler)
  
      trainModel(model=self.model, loader=loader,
                 optimizer=self.optimizer, device=self.device,
                 batches_in_epoch=batches_in_epoch,
                 batch_callback=log)
  
      self.model.postEpoch()
docs: Train one epoch of this model by iterating through mini batches. An epoch
      ends after one pass through the training set, or if the number of mini
      batches exceeds the parameter "batches_in_epoch".