code: def test_empty(
      hypotest, args, kwds, n_samples, n_outputs, paired, unpacker
  ):
      # test for correct output shape when at least one input is empty
  
      if hypotest in override_propagate_funcs:
          reason = (
              "Doesn't follow the usual pattern. Tested separately."
          )
          pytest.skip(reason=reason)
  
      if unpacker is None:
          unpacker = lambda res: (res[0], res[1])  # noqa: E731
  
      def small_data_generator(n_samples, n_dims):
          def small_sample_generator(n_dims):
              # return all possible "small" arrays in up to n_dim dimensions
              for i in n_dims:
                  # "small" means with size along dimension either 0 or 1
                  for combo in combinations_with_replacement(
                      [0, 1, 2], i
                  ):
                      yield np.zeros(combo)
  
          # yield all possible combinations of small samples
          gens = [
              small_sample_generator(n_dims) for i in range(n_samples)
          ]
          yield from product(*gens)
  
      n_dims = [2, 3]
      for samples in small_data_generator(n_samples, n_dims):
          # this test is only for arrays of zero size
          if not any(sample.size == 0 for sample in samples):
              continue
  
          max_axis = max(sample.ndim for sample in samples)
  
          # need to test for all valid values of `axis` parameter, too
          for axis in range(-max_axis, max_axis):
              try:
                  # After broadcasting, all arrays are the same shape, so
                  # the shape of the output should be the same as a single-
                  # sample statistic. Use np.mean as a reference.
                  concat = stats._stats_py._broadcast_concatenate(
                      samples, axis
                  )
                  with np.testing.suppress_warnings() as sup:
                      sup.filter(RuntimeWarning, "Mean of empty slice.")
                      sup.filter(
                          RuntimeWarning, "invalid value encountered"
                      )
                      expected = np.mean(concat, axis=axis) * np.nan
  
                  if hypotest in empty_special_case_funcs:
                      empty_val = hypotest(
                          *([[]] * len(samples)), *args, **kwds
                      )
                      mask = np.isnan(expected)
                      expected[mask] = empty_val
  
                  res = hypotest(*samples, *args, axis=axis, **kwds)
                  res = unpacker(res)
  
                  for i in range(n_outputs):
                      assert_equal(res[i], expected)
  
              except ValueError:
                  # confirm that the arrays truly are not broadcastable
                  assert not _check_arrays_broadcastable(
                      samples, None if paired else axis
                  )
  
                  # confirm that _both_ `_broadcast_concatenate` and `hypotest`
                  # produce this information.
                  message = (
                      "Array shapes are incompatible for broadcasting."
                  )
                  with pytest.raises(ValueError, match=message):
                      stats._stats_py._broadcast_concatenate(
                          samples, axis, paired
                      )
                  with pytest.raises(ValueError, match=message):
                      hypotest(*samples, *args, axis=axis, **kwds)
  
imports: from itertools import product, combinations_with_replacement, permutations
  import re
  import pickle
  import pytest
  import numpy
  from numpy.testing import assert_allclose, assert_equal, suppress_warnings
  from scipy import stats
  from scipy.stats import norm
  from scipy.stats._axis_nan_policy import _masked_arrays_2_sentinel_arrays
  from scipy._lib._util import AxisError
label_desc: Use image node_id 18 for calling a global function with example usage: test_empty(hypotest, args, kwds, n_samples, n_outputs, paired, unpacker) without return types