code: def test_inheritance():
      # no custom init / no custom init
  
      class MyModule(eqx.Module):
          weight: Any
  
      class MyModule2(MyModule):
          weight2: Any
  
      m = MyModule2(1, 2)
      assert m.weight == 1
      assert m.weight2 == 2
      m = MyModule2(1, weight2=2)
      assert m.weight == 1
      assert m.weight2 == 2
      m = MyModule2(weight=1, weight2=2)
      assert m.weight == 1
      assert m.weight2 == 2
      with pytest.raises(TypeError):
          m = MyModule2(2, weight=2)  # pyright: ignore
  
      # not custom init / custom init
  
      class MyModule3(MyModule):
          weight3: Any
  
          def __init__(self, *, weight3: Any, **kwargs):
              self.weight3 = weight3
              super().__init__(**kwargs)
  
      m = MyModule3(weight=1, weight3=3)
      assert m.weight == 1
      assert m.weight3 == 3
  
      # custom init / no custom init
  
      class MyModule4(eqx.Module):
          weight4: Any
  
          def __init__(self, value4: Any, **kwargs):
              self.weight4 = value4
              super().__init__(**kwargs)
  
      class MyModule5(MyModule4):
          weight5: Any
  
      with pytest.raises(TypeError):
          m = MyModule5(value4=1, weight5=2)  # pyright: ignore
  
      class MyModule6(MyModule4):
          pass
  
      m = MyModule6(value4=1)  # pyright: ignore
      assert m.weight4 == 1
  
      # custom init / custom init
  
      class MyModule7(MyModule4):
          weight7: Any
  
          def __init__(self, value7: Any, **kwargs):
              self.weight7 = value7
              super().__init__(**kwargs)
  
      m = MyModule7(value4=1, value7=2)
      assert m.weight4 == 1
      assert m.weight7 == 2
  
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 5 for calling a global function with example usage: test_inheritance() without return types