code: def get_indices(labels, sizes=None, tensors=None):
      indices = []
      start = 0
      if sizes is None:
          sizes = OrderedDict(
              [(l, t.shape[0]) for l, t in tensors.items()]
          )
      for label in sizes:
          end = start + sizes[label]
          if label in labels:
              indices.extend(range(start, end))
          start = end
      return torch.tensor(indices)
  
file_path: pyro/pyro/contrib/util.py
imports: import weakref
  from collections import OrderedDict
  import torch
  import pyro
label_desc: Use image node_id 1 for calling a global function with example usage: get_indices(labels, sizes, tensors) and returns: torch