code: def test_unpack_pack(dims):
      dim_to_symbol = {}
      symbol_to_dim = {}
      for symbol, dim in zip("abcd", range(-1, -5, -1)):
          dim_to_symbol[dim] = symbol
          symbol_to_dim[symbol] = dim
      shape = tuple(range(2, 2 + len(dims)))
      x = torch.randn(shape)
  
      pack_x = packed.pack(x, dim_to_symbol)
      unpack_pack_x = packed.unpack(pack_x, symbol_to_dim)
      assert_equal(unpack_pack_x, x)
  
      sort_dims = "".join(sorted(dims))
      if sort_dims != pack_x._pyro_dims:
          sort_pack_x = pack_x.permute(
              *(pack_x._pyro_dims.index(d) for d in sort_dims)
          )
          sort_pack_x._pyro_dims = sort_dims
          unpack_sort_pack_x = packed.unpack(sort_pack_x, symbol_to_dim)
          assert_equal(unpack_sort_pack_x, x)
  
file_path: pyro/tests/ops/test_packed.py
imports: import itertools
  import random
  import pytest
  import torch
  from torch.distributions.utils import broadcast_all
  from pyro.ops import packed
  from tests.common import assert_equal
label_desc: Use image node_id 1 for calling a global function with example usage: test_unpack_pack(dims) without return types