class_docstr: base trainer class.
  contains methods for training, validation, and writing output.
class_docstr_tok: ["base","trainer","class",".","contains","methods","for","training",",","validation",",","and","writing","output","."]
code: def __init__(
      self,
      opt,
      coarse_net,
      optimizer,
      criterion,
      train_loader,
      val_loader,
      fine_net=None,
  ):
      self.opt = opt
      self.use_cuda = opt.use_cuda
      self.coarse_net = coarse_net
      self.fine_net = fine_net
      self.optim = optimizer
      self.criterion = criterion
      self.train_loader = train_loader
      self.val_loader = val_loader
      self.out = opt.out
      if not os.path.exists(opt.out):
          os.makedirs(opt.out)
      self.epoch = 0
      self.iteration = 0
      self.max_iter = opt.max_iter
      self.valid_iter = opt.valid_iter
      self.tb_pusher = tensorboard_helper.TensorboardPusher(opt)
      self.push_opt_to_tb()
      self.need_resume = opt.resume
      if self.need_resume:
          self.resume()
      if self.opt.load_weights:
          self.load_pretrained_weights()
  
file_path: ml-neuman/trainers/base_trainer.py
imports: import os
  import math
  import abc
  import time
  import tqdm
  from trainers import tensorboard_helper
  from options import options
label_desc: Use image node_id 1 to create a new BaseTrainer object from inherited base classes: abc with example: obj = BaseTrainer(opt, coarse_net, optimizer, criterion, train_loader, val_loader, fine_net)