code: def __init__(self, opts, model, test_loader):
      super(Evaluator, self).__init__()
  
      self.opts = opts
  
      self.model = model
  
      self.test_loader = test_loader
  
      self.device = getattr(opts, "dev.device", torch.device("cpu"))
      self.use_distributed = getattr(
          self.opts, "ddp.use_distributed", False
      )
      self.is_master_node = is_master(opts)
      self.stage_name = getattr(
          opts, "common.eval_stage_name", "evaluation"
      )
  
      self.mixed_precision_training = getattr(
          opts, "common.mixed_precision", False
      )
      self.mixed_precision_dtype = getattr(
          opts, "common.mixed_precision_dtype", "float16"
      )
  
      (
          self.metric_names,
          self.ckpt_metric,
          self.ckpt_submetric,
      ) = parse_validation_metric_names(self.opts)
  
      self.log_writers = get_log_writers(self.opts, save_location=None)
  
      # inference modality based eval function
      self.eval_fn = self.eval_fn_image
      inference_modality = getattr(
          opts, "common.inference_modality", "image"
      )
      if (
          inference_modality is not None
          and inference_modality.lower() == "video"
      ):
          self.eval_fn = self.eval_fn_video
  
file_path: ml-cvnets/engine/evaluation_engine.py
imports: import time
  import torch
  from common import DEFAULT_LOG_FREQ, SUPPORTED_VIDEO_CLIP_VOTING_FN
  from engine.utils import autocast_fn, get_batch_size, get_log_writers
  from metrics.stats import Statistics
  from options.parse_args import parse_validation_metric_names
  from utils import logger
  from utils.common_utils import move_to_device
  from utils.ddp_utils import is_master
label_desc: Use image node_id 1 to create a new Evaluator object from inherited base classes: object with example: obj = Evaluator(opts, model, test_loader)