code: def test_tensor_to_dict():
      sizes = OrderedDict([("a", 2), ("b", 2), ("c", 2)])
      vector = torch.tensor([1.0, 2, 3, 4, 5, 6])
      assert_equal(
          tensor_to_dict(sizes, vector),
          {
              "a": torch.tensor([1.0, 2.0]),
              "b": torch.tensor([3.0, 4.0]),
              "c": torch.tensor([5.0, 6.0]),
          },
      )
      assert_equal(
          tensor_to_dict(sizes, vector, subset=["b"]),
          {"b": torch.tensor([3.0, 4.0])},
      )
  
file_path: pyro/tests/contrib/test_util.py
imports: from collections import OrderedDict
  import pytest
  import torch
  from pyro.contrib.util import get_indices, lexpand, rdiag, rexpand, rmv, rtril, rvv, tensor_to_dict
  from tests.common import assert_equal
label_desc: Use image node_id 2 for calling a global function with example usage: test_tensor_to_dict() without return types