code: def test_rvs_broadcast(dist, shape_args):
      # If shape_only is True, it means the _rvs method of the
      # distribution uses more than one random number to generate a random
      # variate.  That means the result of using rvs with broadcasting or
      # with a nontrivial size will not necessarily be the same as using the
      # numpy.vectorize'd version of rvs(), so we can only compare the shapes
      # of the results, not the values.
      # Whether or not a distribution is in the following list is an
      # implementation detail of the distribution, not a requirement.  If
      # the implementation the rvs() method of a distribution changes, this
      # test might also have to be changed.
      shape_only = dist in [
          "betabinom",
          "betanbinom",
          "skellam",
          "yulesimon",
          "dlaplace",
          "nchypergeom_fisher",
          "nchypergeom_wallenius",
      ]
  
      try:
          distfunc = getattr(stats, dist)
      except TypeError:
          distfunc = dist
          dist = f"rv_discrete(values=({dist.xk!r}, {dist.pk!r}))"
      loc = np.zeros(2)
      nargs = distfunc.numargs
      allargs = []
      bshape = []
      # Generate shape parameter arguments...
      for k in range(nargs):
          shp = (k + 3,) + (1,) * (k + 1)
          param_val = shape_args[k]
          allargs.append(np.full(shp, param_val))
          bshape.insert(0, shp[0])
      allargs.append(loc)
      bshape.append(loc.size)
      # bshape holds the expected shape when loc, scale, and the shape
      # parameters are all broadcast together.
      check_rvs_broadcast(
          distfunc, dist, allargs, bshape, shape_only, [np.dtype(int)]
      )
  
imports: import numpy.testing
  from numpy.testing import assert_allclose
  import numpy
  import pytest
  from scipy import stats
  from .common_tests import check_normalization, check_moment, check_mean_expect, check_var_expect, check_skew_expect, check_kurt_expect, check_entropy, check_private_entropy, check_edge_support, check_named_args, check_random_state_property, check_pickling, check_rvs_broadcast, check_freezing
  from scipy.stats._distr_params import distdiscrete, invdistdiscrete
  from scipy.stats._distn_infrastructure import rv_discrete_frozen
label_desc: Use image node_id 4 for calling a global function with example usage: test_rvs_broadcast(dist, shape_args) without return types