code: def test_broadcast():
      predictor = torch.randn(2, 3, 4)
      # test scenario where `cutpoints.ndim <= predictor.ndim + 1`
      for cp in (
          torch.arange(5),
          torch.arange(5).view(1, -1),
          torch.stack(4 * [torch.arange(5)]),
          torch.sort(torch.randn(3, 4, 5), dim=-1).values,
          torch.sort(
              torch.randn(predictor.shape + (100,)), dim=-1
          ).values,
      ):
          dist = OrderedLogistic(predictor, cp, validate_args=True)
          assert dist.batch_shape == predictor.shape
          assert dist.sample().shape == predictor.shape
  
      # test scenario where `cutpoints.ndim > predictor.ndim + 1`
      # interpretation is broadcasting batches of cutpoints
      cp = torch.sort(torch.randn(10, 2, 3, 4, 5), dim=-1).values
      dist = OrderedLogistic(predictor, cp, validate_args=True)
      assert dist.batch_shape == (10,) + predictor.shape
      assert dist.sample().shape == (10,) + predictor.shape
  
file_path: pyro/tests/distributions/test_ordered_logistic.py
imports: import pytest
  import torch
  from torch.autograd.functional import jacobian
  from pyro.distributions import Normal, OrderedLogistic
  from pyro.distributions.transforms import OrderedTransform
label_desc: Use image node_id 3 for calling a global function with example usage: test_broadcast() without return types