class_docstr: Some common benchmarks that help understand perf bottleneck of a standard dataloader
  made of dataset, mapper and sampler.
class_docstr_tok: ["Some","common","benchmarks","that","help","understand","perf","bottleneck","of","a","standard","dataloader","made","of","dataset",",","mapper","and","sampler","."]
docstr: Benchmark the dataloader by tuning num_workers to [0, 1, self.num_workers].
docstr_tok: ["Benchmark","the","dataloader","by","tuning","num_workers","to","[","0",",","1",",","self.num_workers","]","."]
code: def benchmark_workers(self, num_iter, warmup=10):
      """
      Benchmark the dataloader by tuning num_workers to [0, 1, self.num_workers].
      """
      candidates = [0, 1]
      if self.num_workers not in candidates:
          candidates.append(self.num_workers)
  
      dataset = MapDataset(self.dataset, self.mapper)
      for n in candidates:
          loader = build_batch_data_loader(
              dataset,
              self.sampler,
              self.total_batch_size,
              num_workers=n,
          )
          self._benchmark(
              iter(loader),
              num_iter * max(n, 1),
              warmup * max(n, 1),
              f"DataLoader ({n} workers, bs={self.per_gpu_batch_size})",
          )
          del loader
  
imports: import logging
  import numpy
  from itertools import count
  from typing import List, Tuple
  import torch
  import tqdm
  from fvcore.common.timer import Timer
  from detectron2.utils import comm
  from .build import build_batch_data_loader
  from .common import DatasetFromList, MapDataset
  from .samplers import TrainingSampler
label_desc: Use image node_id 6 for calling the DataLoaderBenchmark obj's underlying member method code with example usage: obj.benchmark_workers(num_iter, warmup) without return types