code: def _get_getitem_method(items, key):
      """Return method to extract values from items.
  
      For the given type of items and type of keys, find the correct
      method to extract the values. By calling this only once per items,
      we can save a lot of type checking, which can be slow if there are
      a lot of epochs and a lot of items. However, we now make the
      assumption that the type of items doesn't change (we know that the
      key doesn't change). This should always be true, except if
      something really weird happens.
  
      We are multi-dispatching based on the following possibilities:
  
      * history[0, 'foo', :10]: get a list of items
      * history[0, 'foo', 0]: get a dict
      * history[0, 'foo', :, 'bar']: key is a str
      * history[0, 'foo', :, ('bar', 'baz')]: key is list/tuple of str
  
      """
      if isinstance(items, list):
          if isinstance(key, list):
              return _getitem_list_list
          if isinstance(key, tuple):
              return _getitem_list_tuple
          if isinstance(key, str):
              return _getitem_list_str
          raise TypeError(
              "History access with given types not supported"
          )
  
      if isinstance(items, dict):
          if isinstance(key, list):
              return _getitem_dict_list
          if isinstance(key, tuple):
              return _getitem_dict_tuple
          if isinstance(key, str):
              return _getitem_dict_str
      raise TypeError("History access with given types not supported")
  
imports: import json
  import pickle
  from skorch.utils import open_file_like
label_desc: Use image node_id 8 for calling a global function with example usage: _get_getitem_method(items, key) and returns: _getitem_list_list, _getitem_list_tuple, _getitem_list_str, _getitem_dict_list, _getitem_dict_tuple, _getitem_dict_str