class_docstr: Map-style DataPipe.
  
  All datasets that represent a map from keys to data samples should subclass this.
  Subclasses should overwrite :meth:`__getitem__`, supporting fetching a
  data sample for a given, unique key. Subclasses can also optionally overwrite
  :meth:`__len__`, which is expected to return the size of the dataset by many
  :class:`~torch.utils.data.Sampler` implementations and the default options
  of :class:`~torch.utils.data.DataLoader`.
  
  These DataPipes can be invoked in two ways, using the class constructor or applying their
  functional form onto an existing `MapDataPipe` (recommend, available to most but not all DataPipes).
  
  Note:
      :class:`~torch.utils.data.DataLoader` by default constructs an index
      sampler that yields integral indices. To make it work with a map-style
      DataPipe with non-integral indices/keys, a custom sampler must be provided.
  
  Example:
      >>> # xdoctest: +SKIP
      >>> from torchdata.datapipes.map import SequenceWrapper, Mapper
      >>> dp = SequenceWrapper(range(10))
      >>> map_dp_1 = dp.map(lambda x: x + 1)  # Using functional form (recommended)
      >>> list(map_dp_1)
      [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
      >>> map_dp_2 = Mapper(dp, lambda x: x + 1)  # Using class constructor
      >>> list(map_dp_2)
      [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
      >>> batch_dp = map_dp_1.batch(batch_size=2)
      >>> list(batch_dp)
      [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]]
class_docstr_tok: ["Map-style","DataPipe",".","All","datasets","that","represent","a","map","from","keys","to","data","samples","should","subclass","this",".","Subclasses","should","overwrite",":","meth",":","`","__getitem__","`",",","supporting","fetching","a","data","sample","for","a","given",",","unique","key",".","Subclasses","can","also","optionally","overwrite",":","meth",":","`","__len__","`",",","which","is","expected","to","return","the","size","of","the","dataset","by","many",":","class",":","`","~torch.utils.data.Sampler","`","implementations","and","the","default","options","of",":","class",":","`","~torch.utils.data.DataLoader","`",".","These","DataPipes","can","be","invoked","in","two","ways",",","using","the","class","constructor","or","applying","their","functional","form","onto","an","existing","`","MapDataPipe","`","(","recommend",",","available","to","most","but","not","all","DataPipes",")",".","Note",":",":","class",":","`","~torch.utils.data.DataLoader","`","by","default","constructs","an","index","sampler","that","yields","integral","indices",".","To","make","it","work","with","a","map-style","DataPipe","with","non-integral","indices\/keys",",","a","custom","sampler","must","be","provided",".","Example",":",">",">",">","#","xdoctest",":","+SKIP",">",">",">","from","torchdata.datapipes.map","import","SequenceWrapper",",","Mapper",">",">",">","dp","=","SequenceWrapper","(","range","(","10",")",")",">",">",">","map_dp_1","=","dp.map","(","lambda","x",":","x","+","1",")","#","Using","functional","form","(","recommended",")",">",">",">","list","(","map_dp_1",")","[","1",",","2",",","3",",","4",",","5",",","6",",","7",",","8",",","9",",","10","]",">",">",">","map_dp_2","=","Mapper","(","dp",",","lambda","x",":","x","+","1",")","#","Using","class","constructor",">",">",">","list","(","map_dp_2",")","[","1",",","2",",","3",",","4",",","5",",","6",",","7",",","8",",","9",",","10","]",">",">",">","batch_dp","=","map_dp_1.batch","(","batch_size=2",")",">",">",">","list","(","batch_dp",")","[","[","1",",","2","]",",","[","3",",","4","]",",","[","5",",","6","]",",","[","7",",","8","]",",","[","9",",","10","]","]"]
docstr: Serialize `lambda` functions when `dill` is available.
  
  If this doesn't cover your custom DataPipe's use case, consider writing custom methods for
  `__getstate__` and `__setstate__`, or use `pickle.dumps` for serialization.
docstr_tok: ["Serialize","`","lambda","`","functions","when","`","dill","`","is","available",".","If","this","does","n't","cover","your","custom","DataPipe","'s","use","case",",","consider","writing","custom","methods","for","`","__getstate__","`","and","`","__setstate__","`",",","or","use","`","pickle.dumps","`","for","serialization","."]
code: def __getstate__(self):
      """
      Serialize `lambda` functions when `dill` is available.
  
      If this doesn't cover your custom DataPipe's use case, consider writing custom methods for
      `__getstate__` and `__setstate__`, or use `pickle.dumps` for serialization.
      """
      state = self.__dict__
      if MapDataPipe.getstate_hook is not None:
          return MapDataPipe.getstate_hook(state)
      return state
  
imports: import functools
  import pickle
  from typing import Dict, Callable, Optional, TypeVar, Generic, Iterator
  from torch.utils.data.datapipes._typing import _DataPipeMeta, _IterDataPipeMeta
  from torch.utils.data.datapipes._hook_iterator import _SnapshotState
  from torch.utils.data.datapipes.utils.common import _deprecation_warning, _iter_deprecated_functional_names, _map_deprecated_functional_names
  from torch.utils.data.dataset import Dataset, IterableDataset
label_desc: Use image node_id 4 for calling the MapDataPipe obj's underlying member method code with example usage: obj.__getstate__() and returns: state, MapDataPipe