code: def test_vonmises_mu_outside_circle():
      # Scipy implementation does not behave as PyTensor/NumPy for mu outside the unit circle
      # We test that the random draws from the JAX dispatch work as expected in these cases
      rng = shared(np.random.RandomState(123))
      mu = np.array([-30, 40])
      kappa = np.array([100, 10])
      g = pt.random.vonmises(mu, kappa, size=(10_000, 2), rng=rng)
      g_fn = compile_random_function([], g, mode=jax_mode)
      samples = g_fn()
      np.testing.assert_allclose(
          samples.mean(axis=0),
          (mu + np.pi) % (2.0 * np.pi) - np.pi,
          rtol=0.1,
      )
  
      # Circvar only does the correct thing in more recent versions of Scipy
      # https://github.com/scipy/scipy/pull/5747
      # np.testing.assert_allclose(
      #     stats.circvar(samples, axis=0),
      #     1 - special.iv(1, kappa) / special.iv(0, kappa),
      #     rtol=0.1,
      # )
  
      # For now simple compare with std from numpy draws
      rng = np.random.default_rng(123)
      ref_samples = rng.vonmises(mu, kappa, size=(10_000, 2))
      np.testing.assert_allclose(
          np.std(samples, axis=0), np.std(ref_samples, axis=0), rtol=0.1
      )
  
imports: import numpy
  import pytest
  import scipy.stats
  import pytensor
  import pytensor.tensor
  import pytensor.tensor.random.basic
  from pytensor.compile.function import function
  from pytensor.compile.sharedvalue import SharedVariable, shared
  from pytensor.graph.basic import Constant
  from pytensor.graph.fg import FunctionGraph
  from pytensor.tensor.random.basic import RandomVariable
  from pytensor.tensor.random.type import RandomType
  from pytensor.tensor.random.utils import RandomStream
  from tests.link.jax.test_basic import compare_jax_and_py, jax_mode, set_test_value
  from pytensor.link.jax.dispatch.random import numpyro_available
label_desc: Use image node_id 18 for calling a global function with example usage: test_vonmises_mu_outside_circle() without return types