class_docstr: Wrap a list to a torch Dataset. It produces elements of the list as data.
class_docstr_tok: ["Wrap","a","list","to","a","torch","Dataset",".","It","produces","elements","of","the","list","as","data","."]
docstr: Args:
      lst (list): a list which contains elements to produce.
      copy (bool): whether to deepcopy the element when producing it,
          so that the result can be modified in place without affecting the
          source in the list.
      serialize (bool or callable): whether to serialize the stroage to other
          backend. If `True`, the default serialize method will be used, if given
          a callable, the callable will be used as serialize method.
docstr_tok: ["Args",":","lst","(","list",")",":","a","list","which","contains","elements","to","produce",".","copy","(","bool",")",":","whether","to","deepcopy","the","element","when","producing","it",",","so","that","the","result","can","be","modified","in","place","without","affecting","the","source","in","the","list",".","serialize","(","bool","or","callable",")",":","whether","to","serialize","the","stroage","to","other","backend",".","If","`","True","`",",","the","default","serialize","method","will","be","used",",","if","given","a","callable",",","the","callable","will","be","used","as","serialize","method","."]
code: def __init__(
      self,
      lst: list,
      copy: bool = True,
      serialize: Union[bool, Callable] = True,
  ):
      """
      Args:
          lst (list): a list which contains elements to produce.
          copy (bool): whether to deepcopy the element when producing it,
              so that the result can be modified in place without affecting the
              source in the list.
          serialize (bool or callable): whether to serialize the stroage to other
              backend. If `True`, the default serialize method will be used, if given
              a callable, the callable will be used as serialize method.
      """
      self._lst = lst
      self._copy = copy
      if not isinstance(serialize, (bool, Callable)):
          raise TypeError(
              f"Unsupported type for argument `serailzie`: {serialize}"
          )
      self._serialize = serialize is not False
  
      if self._serialize:
          serialize_method = (
              serialize
              if isinstance(serialize, Callable)
              else _DEFAULT_DATASET_FROM_LIST_SERIALIZE_METHOD
          )
          logger.info(
              f"Serializing the dataset using: {serialize_method}"
          )
          self._lst = serialize_method(self._lst)
  
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 DatasetFromList object from inherited base classes: data with example: obj = DatasetFromList(lst, copy, serialize)