class_docstr: Sets up a standard trainer
  
  Args:
      device: gpu or cpu
      train_loader: the training data loader
      valid_loader: the validation data loader
      model: the (network) model
      optim: the optimizer
      logger:: the logger to log info
      output_dir: the path to save info
      cfg: a YACS config object.
class_docstr_tok: ["Sets","up","a","standard","trainer","Args",":","device",":","gpu","or","cpu","train_loader",":","the","training","data","loader","valid_loader",":","the","validation","data","loader","model",":","the","(","network",")","model","optim",":","the","optimizer","logger",":",":","the","logger","to","log","info","output_dir",":","the","path","to","save","info","cfg",":","a","YACS","config","object","."]
code: def __init__(
      self,
      device,
      train_loader,
      valid_loader,
      model,
      optim,
      logger,
      output_dir,
      cfg,
  ):
      # misc
      self.device = device
      self.output_dir = output_dir
      # data loader
      self.train_loader = train_loader
      self.valid_loader = valid_loader
      # nn setting
      self.model = model
      self.optim = optim
      # lr setting
      self.criterion = nn.CrossEntropyLoss()
      # training loop settings
      self.epochs = 1
      # loss settings
      self.train_acc, self.valid_acc = [], []
      self.best_valid_acc = 0
      self.ce_loss, self.ortho_loss = 0, 0
      # others
      self.ave_time = 0
      self.logger = logger
      self.cfg = cfg
  
file_path: pykale/examples/cifar_isonet/trainer.py
imports: import time
  import torch
  import torch.nn
  from kale.utils.print import pprint_without_newline, tprint
label_desc: Use image node_id 1 to create a new Trainer object from inherited base classes: object with example: obj = Trainer(device, train_loader, valid_loader, model, optim, logger, output_dir, cfg)