code: def buildModelAndTrain(self, opts):
      log.info(
          "in buildModelAndTrain, trainer_input: {}".format(str(opts))
      )
      log.info("check type self: {}".format(type(self)))
      log.info("check self dir: {}".format(dir(self)))
      log.info("check self source: {}".format(self.__dict__))
      log.info(
          "check self get_input_dataset methods: {}".format(
              inspect.getsource(self.get_input_dataset)
          )
      )
      log.info(
          "check self gen_input_builder_fun method: {}".format(
              inspect.getsource(self.gen_input_builder_fun)
          )
      )
      log.info(
          "check self gen_forward_pass_builder_fun method: {}".format(
              inspect.getsource(self.gen_forward_pass_builder_fun)
          )
      )
      if self.gen_param_update_builder_fun is not None:
          log.info(
              "check self gen_param_update_builder_fun method: {}".format(
                  inspect.getsource(self.gen_param_update_builder_fun)
              )
          )
      else:
          log.info(
              "check self gen_optimizer_fun method: {}".format(
                  inspect.getsource(self.gen_optimizer_fun)
              )
          )
      log.info(
          "check self assembleAllOutputs method: {}".format(
              inspect.getsource(self.assembleAllOutputs)
          )
      )
      log.info(
          "check self prep_data_parallel_models method: {}".format(
              inspect.getsource(self.prep_data_parallel_models)
          )
      )
  
      self.get_model_input_fun()
  
      self.init_model()
  
      self.planning_output()
  
      self.prep_data_parallel_models()
  
      self.loadCheckpoint()
  
      for epoch in self.list_of_epochs():
          log.info("start training epoch {}".format(epoch))
  
          self.fun_per_epoch_b4RunNet(epoch)
  
          for epoch_iter in self.list_of_epoch_iters():
              self.iter_start_time = time.time()
  
              self.fun_per_iter_b4RunNet(epoch, epoch_iter)
  
              if self.train_model is not None:
                  self.run_training_net()
  
              self.fun_per_iter_aftRunNetB4Test(epoch, epoch_iter)
  
              self.iter_end_time = time.time()
  
              if (
                  epoch_iter
                  % opts["epoch_iter"]["num_train_iteration_per_test"]
                  == 0
              ):
                  secs_per_train = (
                      self.iter_end_time - self.iter_start_time
                  )
                  self.secs_per_train.append(secs_per_train)
  
                  sample_trained = self.total_batch_size
                  samples_per_sec = sample_trained / secs_per_train
                  self.samples_per_sec.append(samples_per_sec)
  
                  self.fract_epoch = (
                      epoch + float(epoch_iter) / self.epoch_iterations
                  )
                  self.record_epochs.append(self.fract_epoch)
  
                  for key in self.metrics:
                      metric = self.metrics[key]
                      if not metric["is_train"]:
                          continue
                      metric["calculator"].Add()
                      metric["output"].append(
                          metric["calculator"].Compute()
                      )
  
                  self.test_loop_start_time = time.time()
                  for _test_iter in range(
                      0, opts["epoch_iter"]["num_test_iter"]
                  ):
                      self.run_testing_net()
                      for key in self.metrics:
                          metric = self.metrics[key]
                          if metric["is_train"]:
                              continue
                          metric["calculator"].Add()
                  self.test_loop_end_time = time.time()
                  self.sec_per_test_loop = (
                      self.test_loop_end_time
                      - self.test_loop_start_time
                  )
  
                  for metric in self.metrics.values():
                      if metric["is_train"]:
                          continue
                      metric["output"].append(
                          metric["calculator"].Compute()
                      )
  
                  logStr = "epoch:{}/{} iter:{}/{} secs_per_train:{} ".format(
                      self.fract_epoch,
                      self.opts["epoch_iter"]["num_epochs"],
                      epoch_iter,
                      self.epoch_iterations,
                      secs_per_train,
                  )
                  logStr += "samples_per_sec:{} loop {} tests takes {} sec".format(
                      samples_per_sec,
                      opts["epoch_iter"]["num_test_iter"],
                      self.sec_per_test_loop,
                  )
                  for metric, value in self.metrics.items():
                      logStr += " {}:{} ".format(
                          metric, value["output"][-1]
                      )
                  log.info("Iter Stats: {}".format(logStr))
  
              self.fun_per_iter_aftRunNetAftTest(epoch, epoch_iter)
  
          self.checkpoint(epoch)
  
          self.fun_per_epoch_aftRunNet(epoch)
  
      self.fun_conclude_operator()
  
      self.createMetricsPlotsModelsOutputs()
  
      return self.assembleAllOutputs()
  
imports: from abc import abstractmethod
  from caffe2.python import workspace
  from caffe2.python import timeout_guard
  from caffe2.python import data_parallel_model
  from .None import checkpoint
  from .None import ModuleRegister
  from .None import module_map
  import os
  import inspect
  import time
  import logging
label_desc: Use image node_id 35 for calling the AnyExpTrainer obj's underlying member method code with example usage: obj.buildModelAndTrain(opts) and returns: self