class_docstr: ``SampleList`` is used to collate a list of ``Sample`` into a batch during batch
  preparation. It can be thought of as a merger of list of Dicts into a single Dict.
  
  If ``Sample`` contains an attribute 'text' of size (2) and there are 10 samples in
  list, the returned ``SampleList`` will have an attribute 'text' which is a tensor
  of size (10, 2).
  
  Args:
      samples (type): List of ``Sample`` from which the ``SampleList``
                      will be created.
  
  Usage::
  
      >>> sample_list = [
              Sample({"text": torch.tensor(2)}),
              Sample({"text": torch.tensor(2)})
          ]
      >>> sample_list.text
      torch.tensor([2, 2])
code: def __init__(self, samples=None):
      super().__init__(self)
      if samples is None:
          samples = []
  
      if len(samples) == 0:
          return
  
      if self._check_and_load_dict(samples):
          return
      # If passed sample list was in form of key, value pairs of tuples
      # return after loading these
      if self._check_and_load_tuple(samples):
          return
  
      fields = samples[0].keys()
  
      for field in fields:
          if isinstance(samples[0][field], torch.Tensor):
              size = (len(samples), *samples[0][field].size())
              self[field] = samples[0][field].new_empty(size)
              if self._get_tensor_field() is None:
                  self._set_tensor_field(field)
          else:
              self[field] = [None for _ in range(len(samples))]
  
          for idx, sample in enumerate(samples):
              # it should be a tensor but not a 0-d tensor
              if (
                  isinstance(sample[field], torch.Tensor)
                  and len(sample[field].size()) != 0
                  and sample[field].size(0) != samples[0][field].size(0)
              ):
                  raise AssertionError(
                      "Fields for all samples must be equally sized. "
                      "{} is of different sizes".format(field)
                  )
  
              self[field][idx] = self._get_data_copy(sample[field])
  
          if isinstance(samples[0][field], collections.abc.Mapping):
              self[field] = SampleList(self[field])
  
imports: import collections
  import collections.abc
  import warnings
  from collections import OrderedDict
  from typing import Any, Dict, Union
  import torch
label_desc: Use image node_id 1 to create a new SampleList object from inherited base classes: OrderedDict with example: obj = SampleList(samples)