code: def test_sum_rightmost():
      x = torch.ones(2, 3, 4)
      assert sum_rightmost(x, 0).shape == (2, 3, 4)
      assert sum_rightmost(x, 1).shape == (2, 3)
      assert sum_rightmost(x, 2).shape == (2,)
      assert sum_rightmost(x, -1).shape == (2,)
      assert sum_rightmost(x, -2).shape == (2, 3)
      assert sum_rightmost(x, INF).shape == ()
  
imports: import weakref
  import numpy
  import pytest
  import torch
  from torch.autograd import grad
  import pyro.distributions
  from pyro.distributions import constraints
  from pyro.distributions.util import broadcast_shape, deep_to, detach, sum_leftmost, sum_rightmost, weakmethod
  from pyro.nn.module import PyroModule, PyroParam, PyroSample
  from tests.common import assert_equal
label_desc: Use image node_id 5 for calling a global function with example usage: test_sum_rightmost() without return types