class_docstr: A transform which maps image data from tuple to dict.
  
  This transform has a list of keys (key1, key2, ...),
  takes a sample of the form (data1, data2, ...) and
  returns a sample of the form {key1: data1, key2: data2, ...}
  If duplicate keys are used, the corresponding values are merged into a list.
  
  It is useful for mapping output from datasets like the `PyTorch
  ImageFolder <https://github.com/pytorch/vision/blob/master/torchvision/
  datasets/folder.py#L177>`_ dataset (tuple) to dict with named data fields.
  
  If sample is already a dict with the required keys, pass sample through.
class_docstr_tok: ["A","transform","which","maps","image","data","from","tuple","to","dict",".","This","transform","has","a","list","of","keys","(","key1",",","key2",",","...",")",",","takes","a","sample","of","the","form","(","data1",",","data2",",","...",")","and","returns","a","sample","of","the","form","{","key1",":","data1",",","key2",":","data2",",","...","}","If","duplicate","keys","are","used",",","the","corresponding","values","are","merged","into","a","list",".","It","is","useful","for","mapping","output","from","datasets","like","the","`","PyTorch","ImageFolder","<","https",":","\/\/github.com\/pytorch\/vision\/blob\/master\/torchvision\/","datasets\/folder.py","#","L177",">","`","_","dataset","(","tuple",")","to","dict","with","named","data","fields",".","If","sample","is","already","a","dict","with","the","required","keys",",","pass","sample","through","."]
docstr: Transform sample from type tuple to type dict.
  
  Args:
      sample: input sample which will be transformed
docstr_tok: ["Transform","sample","from","type","tuple","to","type","dict",".","Args",":","sample",":","input","sample","which","will","be","transformed"]
code: def __call__(self, sample):
      """Transform sample from type tuple to type dict.
  
      Args:
          sample: input sample which will be transformed
  
      """
      # If already a dict/map with appropriate keys, exit early
      if isinstance(sample, dict):
          for key in self._map_keys:
              assert (
                  key in sample
              ), "Sample {sample} must be a tuple or a dict with keys {keys}".format(
                  sample=str(sample), keys=str(self._map_keys)
              )
          return sample
  
      assert len(sample) == len(self._map_keys), (
          "Provided sample tuple must have same number of keys "
          "as provided to transform"
      )
      output_sample = collections.defaultdict(list)
      for idx, s in enumerate(sample):
          output_sample[self._map_keys[idx]].append(s)
  
      # Unwrap list if only one item in dict.
      for k, v in output_sample.items():
          if len(v) == 1:
              output_sample[k] = v[0]
  
      return output_sample
  
imports: import collections
  from typing import Any, Callable, Dict, List, Optional, Tuple, Union
  import torchvision.transforms
  from .None import build_transforms, ClassyTransform, register_transform
label_desc: Use image node_id 2 for calling the TupleToMapTransform obj's underlying member method code with example usage: obj.__call__(sample) and returns: output_sample, sample