class_docstr: This trial serves as the trainer for MMDetection models.  It replaces the
  `mmcv runner used by MMDetection
  <https://github.com/open-mmlab/mmdetection/blob/master/mmdet/apis/train.py>`_.
  
  For nearly all use cases, you can just use this trial definition and control behavior
  by changing the MMDetection config.  If you want to customize the trial further, you
  can use this trial as the starting point.
class_docstr_tok: ["This","trial","serves","as","the","trainer","for","MMDetection","models",".","It","replaces","the","`","mmcv","runner","used","by","MMDetection","<","https",":","\/\/github.com\/open-mmlab\/mmdetection\/blob\/master\/mmdet\/apis\/train.py",">","`","_",".","For","nearly","all","use","cases",",","you","can","just","use","this","trial","definition","and","control","behavior","by","changing","the","MMDetection","config",".","If","you","want","to","customize","the","trial","further",",","you","can","use","this","trial","as","the","starting","point","."]
code: def build_validation_data_loader(self) -> det_torch.DataLoader:
      dataset, dataloader = data.build_dataloader(
          self.cfg.data,
          "val",
          self.context,
          False,
      )
  
      def evaluate_fn(results: List[Any]) -> Any:
          # Determined's distributed batch sampler interleaves shards on each GPU slot so
          # sample i goes to worker with rank i % world_size.  Therefore, we need to re-sort
          # all the samples once we gather the predictions before computing the validation metric.
          inds, results = zip(*results)
          inds = [ind for sub_ind in inds for ind in sub_ind]
          results = [res for result in results for res in result]
          sorted_inds = np.argsort(inds)
          results = [results[i] for i in sorted_inds]
  
          eval_kwargs = self.cfg.evaluation
  
          for key in ["interval", "tmpdir", "start", "gpu_collect"]:
              eval_kwargs.pop(key, None)
  
          metrics = dataset.evaluate(results, **eval_kwargs)  # type: ignore
          if not len(metrics):
              return {"bbox_mAP": 0}
          return metrics
  
      self.reducer = self.context.wrap_reducer(
          evaluate_fn, for_training=False, for_validation=True
      )
      return dataloader
  
imports: import logging
  import os
  from typing import Any, Dict, List
  import mmcv
  import mmcv.parallel
  import mmcv.runner
  import mmdet.core
  import mmdet.datasets
  import mmdet.models
  import numpy
  import torch
  import determined.pytorch
  from determined.common import set_logger
  from model_hub import utils
  from model_hub.mmdetection import _callbacks
  from model_hub.mmdetection import _data
  from model_hub.mmdetection import _data_backends
  from model_hub.mmdetection import utils
label_desc: Use image node_id 8 for calling the MMDetTrial obj's underlying member method code with example usage: obj.build_validation_data_loader() and returns: dataloader, metrics, dict