code: def test_check_init():
      class FooException(Exception):
          pass
  
      called_a = False
      called_b = False
  
      class A(eqx.Module):
          a: int
  
          def __check_init__(self):
              nonlocal called_a
              called_a = True
              if self.a >= 0:
                  raise FooException
  
      class B(A):
          def __check_init__(self):
              nonlocal called_b
              called_b = True
  
      class C(A):
          pass
  
      assert not called_a
      assert not called_b
      A(-1)
      assert called_a
      assert not called_b
  
      called_a = False
      with pytest.raises(FooException):
          A(1)
      assert called_a
      assert not called_b
  
      called_a = False
      B(-1)
      assert called_a
      assert called_b
  
      called_a = False
      called_b = False
      with pytest.raises(FooException):
          B(1)
      assert called_a
      assert (
          called_b  # B.__check_init__ is called before A.__check_init__
      )
  
      called_a = False
      called_b = False
      C(-1)
      assert called_a
      assert not called_b
  
      called_a = False
      with pytest.raises(FooException):
          C(1)
      assert called_a
      assert not called_b
  
imports: import abc
  import dataclasses
  import functools
  import inspect
  from collections.abc import Callable
  from dataclasses import InitVar
  from typing import Any, Optional
  import equinox
  import equinox.internal
  import jax
  import jax.numpy
  import jax.tree_util
  import pytest
  from .helpers import tree_allclose
label_desc: Use image node_id 24 for calling a global function with example usage: test_check_init() without return types