code: def __init__(self, opts):
      import logging
  
      logging.basicConfig()
      log = logging.getLogger("AnyExp")
      log.setLevel(logging.DEBUG)
      self.log = log
  
      self.opts = opts
      self.train_dataset = None
      self.test_dataset = None
      self.train_df = None
      self.test_df = None
  
      self.metrics = {}
      self.plotsIngredients = []
  
      self.record_epochs = []
      self.samples_per_sec = []
      self.secs_per_train = []
  
      self.metrics_output = opts["temp_var"]["metrics_output"]
  
      first_xpu = opts["distributed"]["first_xpu_id"]
      num_xpus = opts["distributed"]["num_xpus"]
  
      self.xpus = range(first_xpu, first_xpu + num_xpus)
  
      self.total_batch_size = (
          self.opts["epoch_iter"]["batch_per_device"]
          * self.opts["distributed"]["num_xpus"]
          * self.opts["distributed"]["num_shards"]
      )
      self.epoch_iterations = (
          self.opts["epoch_iter"]["num_train_sample_per_epoch"]
          // self.total_batch_size
      )
  
      if len(opts["input"]["datasets"]) > 0:
          self.train_df = opts["input"]["datasets"][0]
          if len(opts["input"]["datasets"]) == 2:
              self.test_df = opts["input"]["datasets"][1]
      # at this point, the intance of this class becomes many instances
      # running on different machines.  Most of their attributes are same,
      # but the shard_ids are different.
      self.shard_id = opts["temp_var"]["shard_id"]
      self.start_epoch = opts["temp_var"]["start_epoch"]
      self.epoch = opts["temp_var"]["epoch"]
      self.epochs_to_run = opts["epoch_iter"][
          "num_epochs_per_flow_schedule"
      ]
  
      log.info("opts: {}".format(str(opts)))
  
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 1 to create a new AnyExpTrainer object  with example: obj = AnyExpTrainer(opts)