code: def test_value(x_shape, i_shape, j_shape, event_shape):
      x = torch.rand(x_shape + (5, 6) + event_shape)
      i = dist.Categorical(torch.ones(5)).sample(i_shape)
      j = dist.Categorical(torch.ones(6)).sample(j_shape)
      if event_shape:
          actual = Vindex(x)[..., i, j, :]
      else:
          actual = Vindex(x)[..., i, j]
  
      shape = broadcast_shape(x_shape, i_shape, j_shape)
      x = x.expand(shape + (5, 6) + event_shape)
      i = i.expand(shape)
      j = j.expand(shape)
      expected = x.new_empty(shape + event_shape)
      for ind in (
          itertools.product(*map(range, shape)) if shape else [()]
      ):
          expected[ind] = x[ind + (i[ind].item(), j[ind].item())]
      assert_equal(actual, expected)
  
file_path: pyro/tests/ops/test_indexing.py
imports: import itertools
  import pytest
  import torch
  import pyro.distributions
  from pyro.distributions.util import broadcast_shape
  from pyro.ops.indexing import Index, Vindex
  from tests.common import assert_equal
label_desc: Use image node_id 3 for calling a global function with example usage: test_value(x_shape, i_shape, j_shape, event_shape) without return types