code: def test_rdiag():
      v = torch.tensor([1.0, 2.0, -1.0])
      assert_equal(rdiag(v), torch.diag(v), prec=1e-8)
      expanded = lexpand(v, 5, 4)
      expeceted = lexpand(torch.diag(v), 5, 4)
      assert_equal(rdiag(expanded), expeceted, prec=1e-8)
  
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 8 for calling a global function with example usage: test_rdiag() without return types