code: def tensor_to_dict(sizes, tensor, subset=None):
      if subset is None:
          subset = sizes.keys()
      start = 0
      out = {}
      for label, size in sizes.items():
          end = start + size
          if label in subset:
              out[label] = tensor[..., start:end]
          start = end
      return out
  
file_path: pyro/pyro/contrib/util.py
imports: import weakref
  from collections import OrderedDict
  import torch
  import pyro
label_desc: Use image node_id 2 for calling a global function with example usage: tensor_to_dict(sizes, tensor, subset) and returns: out