code: def unflatten(
      flat_sample, output_dims, contract_dims, contract_shape
  ):
      """
      Unpack a collection of indices that have been packed into a 64-bit
      tensor, via modular arithmetic.
      """
      assert contract_dims
      sample = flat_sample.unsqueeze(0)
      if len(contract_dims) > 1:
          slices = [None] * len(contract_dims)
          for i, size in reversed(list(enumerate(contract_shape))):
              slices[i] = sample % size
              sample = sample // size
          sample = torch.cat(slices)
      sample._pyro_dims = SAMPLE_SYMBOL + output_dims
      sample._pyro_sample_dims = contract_dims
      assert sample.dim() == len(sample._pyro_dims)
      if not torch._C._get_tracing_state():
          assert sample.size(0) == len(sample._pyro_sample_dims)
      return sample
  
imports: import weakref
  from abc import ABCMeta, abstractmethod
  import torch
  from pyro.ops import packed
  from pyro.util import jit_iter
label_desc: Use image node_id 4 for calling a global function with example usage: unflatten(flat_sample, output_dims, contract_dims, contract_shape) and returns: sample