code: def test_rng_trace_level_constraints(self):
      rngs = nnx.Rngs(0)
  
      @jax.jit
      def f():
          with pytest.raises(
              nnx.TraceContextError,
              match="Cannot use Rngs from a different trace level",
          ):
              rngs.params()
  
      f()
  
      @jax.jit
      def f():
          with pytest.raises(
              nnx.TraceContextError,
              match="Cannot use Rngs from a different trace level",
          ):
              rngs.fork()
  
      f()
  
      rngs1: Any = None
  
      @jax.jit
      def g():
          nonlocal rngs1
          rngs1 = nnx.Rngs(1)
  
      g()
  
      assert isinstance(rngs1, nnx.Rngs)
      with pytest.raises(
          nnx.TraceContextError,
          match="Cannot use Rngs from a different trace level",
      ):
          rngs1.params()
  
imports: from typing import Any
  import jax
  import jax.numpy
  import pytest
  from flax.experimental import nnx
  from flax.experimental.nnx.nnx.rnglib import _stable_hash
label_desc: Use image node_id 7 for calling the TestRngs obj's underlying member method code with example usage: obj.test_rng_trace_level_constraints() without return types