docstr: Train the model, it trains model weights and architecute weights.
  Architecture weights are trained according to the schedule.
  Before updating architecture weights, ```requires_grad``` is enabled.
  Then, it is disabled after the updating, in order not to update
  architecture weights when training model weights.
docstr_tok: ["Train","the","model",",","it","trains","model","weights","and","architecute","weights",".","Architecture","weights","are","trained","according","to","the","schedule",".","Before","updating","architecture","weights",",","``","`","requires_grad","``","`","is","enabled",".","Then",",","it","is","disabled","after","the","updating",",","in","order","not","to","update","architecture","weights","when","training","model","weights","."]
code: def _train(self):
      """
      Train the model, it trains model weights and architecute weights.
      Architecture weights are trained according to the schedule.
      Before updating architecture weights, ```requires_grad``` is enabled.
      Then, it is disabled after the updating, in order not to update
      architecture weights when training model weights.
      """
      arch_param_num = self.mutator.num_arch_params()
      self.logger.info("#arch_params: {}".format(arch_param_num))
      self.epoch = max(self.start_epoch, self.epoch)
  
      ckpt_path = self.config.model_dir
      choice_names = None
      val_nme = 1e6
  
      for epoch in range(self.epoch, self.n_epochs):
          # update the weight parameters
          self.logger.info(
              "\n--------Train epoch: %d--------\n", epoch + 1
          )
          self._train_epoch(epoch, self.model_optim)
          # adjust learning rate
          self.scheduler.step()
  
          # update the architecture parameters
          self.logger.info("Update architecture parameters")
          self.mutator.arch_requires_grad()
          self._train_epoch(epoch, self.arch_optimizer, True)
          self.mutator.arch_disable_grad()
          # temperature annealing
          self.temp = self.temp * self.exp_anneal_rate
          self.mutator.set_temperature(self.temp)
          # sample the architecture of sub-network
          choice_names = self._layer_choice_sample()
  
          # validate
          _, nme = self._validate()
  
          if epoch % 10 == 0:
              filename = os.path.join(
                  ckpt_path, "checkpoint_%s.pth" % epoch
              )
              self.save_checkpoint(epoch, filename, choice_names)
  
          if nme < val_nme:
              filename = os.path.join(ckpt_path, "checkpoint_best.pth")
              self.save_checkpoint(epoch, filename, choice_names)
              val_nme = nme
          self.logger.info("Best nme: {:.4f}".format(val_nme))
  
file_path: nni/examples/nas/legacy/oneshot/pfld/lib/trainer.py
imports: from __future__ import absolute_import, division, print_function
  import os
  import time
  import torch
  import numpy
  from nni.algorithms.nas.pytorch.fbnet import FBNetTrainer
  from nni.nas.pytorch.utils import AverageMeter
  from .utils import accuracy
label_desc: Use image node_id 5 for calling the PFLDTrainer obj's underlying member method code with example usage: obj._train() without return types