code: def test_subclass_overrides_base(self):
      # Note: if a base class declares a field as keyword-only, then
      # subclasses don't need to also declare it as keyword-only.
  
      @kw_only_dataclasses.dataclass
      class A:
          x: int = kw_only_dataclasses.field(default=1, kw_only=True)
  
      @kw_only_dataclasses.dataclass
      class B(A):
          size: float
          y: int = kw_only_dataclasses.field(default=3, kw_only=True)
          x: int = 2
  
      @kw_only_dataclasses.dataclass
      class C(B):
          name: str
  
      a_params = inspect.signature(A.__init__).parameters
      b_params = inspect.signature(B.__init__).parameters
      c_params = inspect.signature(C.__init__).parameters
  
      self.assertEqual(list(a_params), ["self", "x"])
      self.assertEqual(list(b_params), ["self", "size", "x", "y"])
      self.assertEqual(
          list(c_params), ["self", "size", "name", "x", "y"]
      )
  
      self.assertEqual(a_params["x"].default, 1)
      self.assertEqual(b_params["x"].default, 2)
      self.assertEqual(b_params["y"].default, 3)
      self.assertEqual(
          b_params["size"].default, inspect.Parameter.empty
      )
      self.assertEqual(c_params["x"].default, 2)
      self.assertEqual(c_params["y"].default, 3)
      self.assertEqual(
          c_params["name"].default, inspect.Parameter.empty
      )
      self.assertEqual(
          c_params["size"].default, inspect.Parameter.empty
      )
  
      value = C(4, "foo")  # pylint: disable=too-many-function-args
      self.assertDictEqual(
          dataclasses.asdict(value), dict(name="foo", size=4, x=2, y=3)
      )
  
file_path: flax/tests/linen/kw_only_dataclasses_test.py
imports: import dataclasses
  import inspect
  from absl.testing import absltest
  from flax.linen import kw_only_dataclasses
label_desc: Use image node_id 3 for calling the KwOnlyDataclassesTest obj's underlying member method code with example usage: obj.test_subclass_overrides_base() without return types