def METHOD_NAME(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