original_docstring: 
      Run model on the data_loader and evaluate the metrics with evaluator.
      The model will be used in eval mode.
  
      Args:
          model (nn.Module): a module which accepts an object from
              `data_loader` and returns some outputs. It will be temporarily set to `eval` mode.
  
              If you wish to evaluate a model in `training` mode instead, you can
              wrap the given model and override its behavior of `.eval()` and `.train()`.
          data_loader: an iterable object with a length.
              The elements it generates will be the inputs to the model.
          evaluator (DatasetEvaluator): the evaluator to run. Use
              :class:`DatasetEvaluators([])` if you only want to benchmark, but
              don't want to do any evaluation.
  
      Returns:
          The return value of `evaluator.evaluate()`
      
docstring: Run model on the data_loader and evaluate the metrics with evaluator.
  The model will be used in eval mode.
docstring_tokens: Run model on the data_loader and evaluate the metrics with evaluator . The model will be used in eval mode .
code: def inference_on_dataset(model, data_loader, evaluator, prop_evaluator, use_cls=False):
      """
      Run model on the data_loader and evaluate the metrics with evaluator.
      The model will be used in eval mode.
  
      Args:
          model (nn.Module): a module which accepts an object from
              `data_loader` and returns some outputs. It will be temporarily set to `eval` mode.
  
              If you wish to evaluate a model in `training` mode instead, you can
              wrap the given model and override its behavior of `.eval()` and `.train()`.
          data_loader: an iterable object with a length.
              The elements it generates will be the inputs to the model.
          evaluator (DatasetEvaluator): the evaluator to run. Use
              :class:`DatasetEvaluators([])` if you only want to benchmark, but
              don't want to do any evaluation.
  
      Returns:
          The return value of `evaluator.evaluate()`
      """
      num_devices = torch.distributed.get_world_size() if torch.distributed.is_initialized() else 1
      logger = logging.getLogger(__name__)
      logger.info("Start inference on {} images".format(len(data_loader)))
  
      total = len(data_loader)  # inference data loader must have a fixed length
      evaluator.reset()
      prop_evaluator.reset()
  
      logging_interval = 50
      num_warmup = min(5, logging_interval - 1, total - 1)
      start_time = time.time()
      total_compute_time = 0
      with inference_context(model), torch.no_grad():
          for idx, inputs in enumerate(data_loader):
              if idx == num_warmup:
                  start_time = time.time()
                  total_compute_time = 0
  
              start_compute_time = time.time()
              outputs, proposals, logs = model(inputs)
              torch.cuda.synchronize()
              total_compute_time += time.time() - start_compute_time
  
              evaluator.process(inputs, outputs)
              prop_evaluator.process(inputs, proposals)
  
              if (idx + 1) % logging_interval == 0:
                  duration = time.time() - start_time
                  seconds_per_img = duration / (idx + 1 - num_warmup)
                  eta = datetime.timedelta(
                      seconds=int(seconds_per_img * (total - num_warmup) - duration)
                  )
                  logger.info(
                      "Inference done {}/{}. {:.4f} s / img. ETA={}".format(
                          idx + 1, total, seconds_per_img, str(eta)
                      )
                  )
                  #break
  
      # Measure the time only for this worker (before the synchronization barrier)
      total_time = int(time.time() - start_time)
      total_time_str = str(datetime.timedelta(seconds=total_time))
      # NOTE this format is parsed by grep
      logger.info(
          "Total inference time: {} ({:.6f} s / img per device, on {} devices)".format(
              total_time_str, total_time / (total - num_warmup), num_devices
          )
      )
      total_compute_time_str = str(datetime.timedelta(seconds=int(total_compute_time)))
      logger.info(
          "Total inference pure compute time: {} ({:.6f} s / img per device, on {} devices)".format(
              total_compute_time_str, total_compute_time / (total - num_warmup), num_devices
          )
      )
  
      prop_results = prop_evaluator.evaluate()
      results = evaluator.evaluate()
      # An evaluator may return None when not in main process.
      # Replace it by an empty dict instead to make it easier for downstream code to handle
      if results is None:
          results = {}
  
      if prop_results is None:
          prop_results = {}
  
      return results, prop_results
code_tokens: def inference_on_dataset ( model , data_loader , evaluator , prop_evaluator , use_cls = False ) : num_devices = torch . distributed . get_world_size ( ) if torch . distributed . is_initialized ( ) else 1 logger = logging . getLogger ( __name__ ) logger . info ( "Start inference on {} images" . format ( len ( data_loader ) ) ) total = len ( data_loader ) evaluator . reset ( ) prop_evaluator . reset ( ) logging_interval = 50 num_warmup = min ( 5 , logging_interval - 1 , total - 1 ) start_time = time . time ( ) total_compute_time = 0 with inference_context ( model ) , torch . no_grad ( ) : for idx , inputs in enumerate ( data_loader ) : if idx == num_warmup : start_time = time . time ( ) total_compute_time = 0 start_compute_time = time . time ( ) outputs , proposals , logs = model ( inputs ) torch . cuda . synchronize ( ) total_compute_time += time . time ( ) - start_compute_time evaluator . process ( inputs , outputs ) prop_evaluator . process ( inputs , proposals ) if ( idx + 1 ) % logging_interval == 0 : duration = time . time ( ) - start_time seconds_per_img = duration / ( idx + 1 - num_warmup ) eta = datetime . timedelta ( seconds = int ( seconds_per_img * ( total - num_warmup ) - duration ) ) logger . info ( "Inference done {}/{}. {:.4f} s / img. ETA={}" . format ( idx + 1 , total , seconds_per_img , str ( eta ) ) ) total_time = int ( time . time ( ) - start_time ) total_time_str = str ( datetime . timedelta ( seconds = total_time ) ) logger . info ( "Total inference time: {} ({:.6f} s / img per device, on {} devices)" . format ( total_time_str , total_time / ( total - num_warmup ) , num_devices ) ) total_compute_time_str = str ( datetime . timedelta ( seconds = int ( total_compute_time ) ) ) logger . info ( "Total inference pure compute time: {} ({:.6f} s / img per device, on {} devices)" . format ( total_compute_time_str , total_compute_time / ( total - num_warmup ) , num_devices ) ) prop_results = prop_evaluator . evaluate ( ) results = evaluator . evaluate ( ) if results is None : results = { } if prop_results is None : prop_results = { } return results , prop_results
short_docstring: Run model on the data_loader and evaluate the metrics with evaluator.
short_docstring_tokens: Run model on the data_loader and evaluate the metrics with evaluator .
comment: """
      Run model on the data_loader and evaluate the metrics with evaluator.
      The model will be used in eval mode.
  
      Args:
          model (nn.Module): a module which accepts an object from
              `data_loader` and returns some outputs. It will be temporarily set to `eval` mode.
  
              If you wish to evaluate a model in `training` mode instead, you can
              wrap the given model and override its behavior of `.eval()` and `.train()`.
          data_loader: an iterable object with a length.
              The elements it generates will be the inputs to the model.
          evaluator (DatasetEvaluator): the evaluator to run. Use
              :class:`DatasetEvaluators([])` if you only want to benchmark, but
              don't want to do any evaluation.
  
      Returns:
          The return value of `evaluator.evaluate()`
      """$SEP$# inference data loader must have a fixed length$SEP$#break$SEP$# Measure the time only for this worker (before the synchronization barrier)$SEP$# NOTE this format is parsed by grep$SEP$# An evaluator may return None when not in main process.$SEP$# Replace it by an empty dict instead to make it easier for downstream code to handle