code: def build_detection_test_loader(cfg, dataset_name, mapper=None):
      """
      Similar to `build_detection_train_loader`.
      But this function uses the given `dataset_name` argument (instead of the names in cfg),
      and uses batch size 1.
  
      Args:
          cfg: a detectron2 CfgNode
          dataset_name (str): a name of the dataset that's available in the DatasetCatalog
          mapper (callable): a callable which takes a sample (dict) from dataset
             and returns the format to be consumed by the model.
             By default it will be `DatasetMapper.from_config(cfg, False)`.
  
      Returns:
          DataLoader: a torch DataLoader, that loads the given detection
          dataset, with test-time transformation and batching.
      """
      dataset_dicts = get_detection_dataset_dicts(
          [dataset_name],
          filter_empty=False,
          proposal_files=[
              cfg.CONFIG.DATA.DATASET.PROPOSAL_FILES_TEST[
                  list(
                      cfg.CONFIG.DATA.DATASET.PROPOSAL_FILES_TEST
                  ).index(dataset_name)
              ]
          ]
          if cfg.CONFIG.DATA.LOAD_PROPOSALS
          else None,
      )
  
      dataset = DatasetFromList(dataset_dicts)
      if mapper is None:
          mapper = DatasetMapper.from_config(cfg, False)
      dataset = MapDataset(dataset, mapper)
  
      sampler = InferenceSampler(len(dataset))
      # Always use 1 image per worker during inference since this is the
      # standard when reporting inference time in papers.
      batch_sampler = torch.utils.data.sampler.BatchSampler(
          sampler, 1, drop_last=False
      )
  
      data_loader = torch.utils.data.DataLoader(
          dataset,
          num_workers=cfg.CONFIG.DATA.NUM_WORKERS,
          batch_sampler=batch_sampler,
          collate_fn=trivial_batch_collator,
      )
      return data_loader
  
imports: import itertools
  import random
  import logging
  import operator
  import dill
  import pickle
  from pprint import pformat
  from typing import List, Optional, Union
  import numpy
  import torch
  import torch.utils.data
  from ..structures import BoxMode
  from ...utils.comm import get_world_size
  from ...utils.random import seed_all_rng
  from ..transforms import instance_transforms
  from ..registry.catalog import DatasetCatalog, MetadataCatalog
  from .detection_utils import check_metadata_consistency
  from .None import detection_utils
  from .samplers import InferenceSampler, RepeatFactorTrainingSampler, TrainingSampler
label_desc: Use image node_id 8 for calling a global function with example usage: build_detection_test_loader(cfg, dataset_name, mapper) and returns: data_loader