class_docstr: A wrapper of concatenated dataset.
  
  Same as ``torch.utils.data.dataset.ConcatDataset``, support
  lazy_init and get_dataset_source.
  
  Note:
      ``ConcatDataset`` should not inherit from ``BaseDataset`` since
      ``get_subset`` and ``get_subset_`` could produce ambiguous meaning
      sub-dataset which conflicts with original dataset. If you want to use
      a sub-dataset of ``ConcatDataset``, you should set ``indices``
      arguments for wrapped dataset which inherit from ``BaseDataset``.
  
  Args:
      datasets (Sequence[BaseDataset] or Sequence[dict]): A list of datasets
          which will be concatenated.
      lazy_init (bool, optional): Whether to load annotation during
          instantiation. Defaults to False.
      ignore_keys (List[str] or str): Ignore the keys that can be
          unequal in `dataset.metainfo`. Defaults to None.
          `New in version 0.3.0.`
class_docstr_tok: ["A","wrapper","of","concatenated","dataset",".","Same","as","``","torch.utils.data.dataset.ConcatDataset","``",",","support","lazy_init","and","get_dataset_source",".","Note",":","``","ConcatDataset","``","should","not","inherit","from","``","BaseDataset","``","since","``","get_subset","``","and","``","get_subset_","``","could","produce","ambiguous","meaning","sub-dataset","which","conflicts","with","original","dataset",".","If","you","want","to","use","a","sub-dataset","of","``","ConcatDataset","``",",","you","should","set","``","indices","``","arguments","for","wrapped","dataset","which","inherit","from","``","BaseDataset","``",".","Args",":","datasets","(","Sequence","[","BaseDataset","]","or","Sequence","[","dict","]",")",":","A","list","of","datasets","which","will","be","concatenated",".","lazy_init","(","bool",",","optional",")",":","Whether","to","load","annotation","during","instantiation",".","Defaults","to","False",".","ignore_keys","(","List","[","str","]","or","str",")",":","Ignore","the","keys","that","can","be","unequal","in","`","dataset.metainfo","`",".","Defaults","to","None",".","`","New","in","version","0.3.0.","`"]
code: def __init__(
      self,
      datasets: Sequence[Union[BaseDataset, dict]],
      lazy_init: bool = False,
      ignore_keys: Union[str, List[str], None] = None,
  ):
      self.datasets: List[BaseDataset] = []
      for i, dataset in enumerate(datasets):
          if isinstance(dataset, dict):
              self.datasets.append(DATASETS.build(dataset))
          elif isinstance(dataset, BaseDataset):
              self.datasets.append(dataset)
          else:
              raise TypeError(
                  "elements in datasets sequence should be config or "
                  f"`BaseDataset` instance, but got {type(dataset)}"
              )
      if ignore_keys is None:
          self.ignore_keys = []
      elif isinstance(ignore_keys, str):
          self.ignore_keys = [ignore_keys]
      elif isinstance(ignore_keys, list):
          self.ignore_keys = ignore_keys
      else:
          raise TypeError(
              "ignore_keys should be a list or str, "
              f"but got {type(ignore_keys)}"
          )
  
      meta_keys: set = set()
      for dataset in self.datasets:
          meta_keys |= dataset.metainfo.keys()
      # if the metainfo of multiple datasets are the same, use metainfo
      # of the first dataset, else the metainfo is a list with metainfo
      # of all the datasets
      is_all_same = True
      self._metainfo_first = self.datasets[0].metainfo
      for i, dataset in enumerate(self.datasets, 1):
          for key in meta_keys:
              if key in self.ignore_keys:
                  continue
              if key not in dataset.metainfo:
                  is_all_same = False
                  break
              if self._metainfo_first[key] != dataset.metainfo[key]:
                  is_all_same = False
                  break
  
      if is_all_same:
          self._metainfo = self.datasets[0].metainfo
      else:
          self._metainfo = [
              dataset.metainfo for dataset in self.datasets
          ]
  
      self._fully_initialized = False
      if not lazy_init:
          self.full_init()
  
          if is_all_same:
              self._metainfo.update(
                  dict(cumulative_sizes=self.cumulative_sizes)
              )
          else:
              for i, dataset in enumerate(self.datasets):
                  self._metainfo[i].update(
                      dict(cumulative_sizes=self.cumulative_sizes)
                  )
  
file_path: mmdetection/mmdet/datasets/dataset_wrappers.py
imports: import collections
  import copy
  from typing import List, Sequence, Union
  from mmengine.dataset import BaseDataset
  from mmengine.dataset import ConcatDataset
  from mmengine.dataset import force_full_init
  from mmdet.registry import DATASETS, TRANSFORMS
label_desc: Use image node_id 1 to create a new ConcatDataset object from inherited base classes: MMENGINE_ConcatDataset with example: obj = ConcatDataset(datasets, lazy_init, ignore_keys)