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])
docstr: Add an attribute ``field`` with value ``data`` to the SampleList
  
  Args:
      field (str): Key under which the data will be added.
      data (object): Data to be added, can be a ``torch.Tensor``, ``list``
                   or ``Sample``
code: def add_field(self, field, data):
      """Add an attribute ``field`` with value ``data`` to the SampleList
  
      Args:
          field (str): Key under which the data will be added.
          data (object): Data to be added, can be a ``torch.Tensor``, ``list``
                       or ``Sample``
      """
      fields = self.fields()
      tensor_field = self._get_tensor_field()
  
      if (
          len(fields) != 0
          and isinstance(data, torch.Tensor)
          and len(data.size()) != 0
          and tensor_field is not None
          and data.size(0) != self[tensor_field].size(0)
      ):
          raise AssertionError(
              "A tensor field to be added must "
              "have same size as existing tensor "
              "fields in SampleList. "
              "Passed size: {}, Required size: {}".format(
                  len(data), len(self[tensor_field])
              )
          )
  
      if isinstance(data, collections.abc.Mapping):
          self[field] = SampleList(data)
      else:
          self[field] = self._get_data_copy(data)
  
          if (
              isinstance(self[field], torch.Tensor)
              and tensor_field is None
          ):
              self._set_tensor_field(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 17 for calling the SampleList obj's underlying member method code with example usage: obj.add_field(field, data) without return types