code: def test_nonfinite(func, numargs):
      rng = np.random.default_rng(1701299355559735)
      func = getattr(sp, func)
      args_choices = [
          (float(x), np.nan, np.inf, -np.inf)
          for x in rng.random(numargs)
      ]
  
      for args in itertools.product(*args_choices):
          res = func(*args)
  
          if any(np.isnan(x) for x in args):
              # Nan inputs should result to nan output
              assert_equal(res, np.nan)
          else:
              # All other inputs should return something (but not
              # raise exceptions or cause hangs)
              pass
  
imports: import itertools
  import numpy
  from numpy.testing import assert_equal, assert_allclose
  import pytest
  import scipy.special
  from scipy.special._testutils import MissingModule, check_version, FuncData
  from scipy.special._mptestutils import Arg, IntArg, get_args, mpf2float, assert_mpmath_equal
label_desc: Use image node_id 8 for calling a global function with example usage: test_nonfinite(func, numargs) without return types