code: def test_expand_existing_dim(dist, shape_type, default):
      for idx in range(dist.get_num_test_data()):
          small = dist.pyro_dist(**dist.get_dist_params(idx))
          for dim, size in enumerate(small.batch_shape):
              if size != 1:
                  continue
              batch_shape = list(small.batch_shape)
              batch_shape[dim] = 5
              batch_shape = torch.Size(batch_shape)
              if default:
                  large = TorchDistribution.expand(
                      small, shape_type(batch_shape)
                  )
              else:
                  with xfail_if_not_implemented():
                      large = small.expand(shape_type(batch_shape))
              assert large.batch_shape == batch_shape
              if dist.get_test_distribution_name() == "Stable":
                  pytest.skip(
                      "Stable does not implement a log_prob method."
                  )
              check_sample_shapes(small, large)
  
imports: import numpy
  import pytest
  import torch
  import pyro
  import pyro.distributions
  from pyro.distributions import TorchDistribution
  from pyro.distributions.testing.gof import auto_goodness_of_fit
  from pyro.distributions.util import broadcast_shape
  from tests.common import TEST_FAILURE_RATE, assert_close, assert_equal, xfail_if_not_implemented
label_desc: Use image node_id 21 for calling a global function with example usage: test_expand_existing_dim(dist, shape_type, default) without return types