class_docstr: Map a function over the elements in a dataset.
class_docstr_tok: ["Map","a","function","over","the","elements","in","a","dataset","."]
docstr: Args:
      dataset: a dataset where map function is applied. Can be either
          map-style or iterable dataset. When given an iterable dataset,
          the returned object will also be an iterable dataset.
      map_func: a callable which maps the element in dataset. map_func can
          return None to skip the data (e.g. in case of errors).
          How None is handled depends on the style of `dataset`.
          If `dataset` is map-style, it randomly tries other elements.
          If `dataset` is iterable, it skips the data and tries the next.
docstr_tok: ["Args",":","dataset",":","a","dataset","where","map","function","is","applied",".","Can","be","either","map-style","or","iterable","dataset",".","When","given","an","iterable","dataset",",","the","returned","object","will","also","be","an","iterable","dataset",".","map_func",":","a","callable","which","maps","the","element","in","dataset",".","map_func","can","return","None","to","skip","the","data","(","e.g",".","in","case","of","errors",")",".","How","None","is","handled","depends","on","the","style","of","`","dataset","`",".","If","`","dataset","`","is","map-style",",","it","randomly","tries","other","elements",".","If","`","dataset","`","is","iterable",",","it","skips","the","data","and","tries","the","next","."]
code: def __init__(self, dataset, map_func):
      """
      Args:
          dataset: a dataset where map function is applied. Can be either
              map-style or iterable dataset. When given an iterable dataset,
              the returned object will also be an iterable dataset.
          map_func: a callable which maps the element in dataset. map_func can
              return None to skip the data (e.g. in case of errors).
              How None is handled depends on the style of `dataset`.
              If `dataset` is map-style, it randomly tries other elements.
              If `dataset` is iterable, it skips the data and tries the next.
      """
      self._dataset = dataset
      self._map_func = PicklableWrapper(
          map_func
      )  # wrap so that a lambda will work
  
      self._rng = random.Random(42)
      self._fallback_candidates = set(range(len(dataset)))
  
imports: import contextlib
  import copy
  import itertools
  import logging
  import numpy
  import pickle
  import random
  from typing import Callable, Union
  import torch
  import torch.utils.data
  from torch.utils.data.sampler import Sampler
  from detectron2.utils.serialize import PicklableWrapper
label_desc: Use image node_id 1 to create a new MapDataset object from inherited base classes: data with example: obj = MapDataset(dataset, map_func)