code: def test_to_event(base_dist):
      base_dist = base_dist.expand([2, 3])
      d = base_dist
      expected_event_dim = d.event_dim
  
      d = d.to_event(0)
      assert d is base_dist
  
      d = d.to_event(1)
      expected_event_dim += 1
      assert d.event_dim == expected_event_dim
      assert d.base_dist is base_dist
  
      d = d.to_event(0)
      assert d.event_dim == expected_event_dim
      assert d.base_dist is base_dist
  
      d = d.to_event(1)
      expected_event_dim += 1
      assert d.event_dim == expected_event_dim
      assert d.base_dist is base_dist
  
      d = d.to_event(0)
      assert d.event_dim == expected_event_dim
      assert d.base_dist is base_dist
  
      d = d.to_event(-1)
      expected_event_dim += -1
      assert d.event_dim == expected_event_dim
      assert d.base_dist is base_dist
  
      d = d.to_event(0)
      assert d.event_dim == expected_event_dim
      assert d.base_dist is base_dist
  
      d = d.to_event(-1)
      expected_event_dim += -1
      assert d is base_dist
  
file_path: pyro/tests/distributions/test_independent.py
imports: import pytest
  import torch
  from torch.distributions.utils import _sum_rightmost
  import pyro.distributions
  from pyro.util import torch_isnan
  from tests.common import assert_equal
label_desc: Use image node_id 2 for calling a global function with example usage: test_to_event(base_dist) without return types