code: def test_only_infer_superclass_params_if_unknown(self):
      from allennlp.common.registrable import Registrable
  
      class BaseClass(Registrable):
          def __init__(self):
              self.x = None
              self.a = None
              self.rest = None
  
      @BaseClass.register("a")
      class A(BaseClass):
          def __init__(self, a: int, x: int, **kwargs):
              super().__init__()
              self.x = x
              self.a = a
              self.rest = kwargs
  
      @BaseClass.register("b")
      class B(A):
          def __init__(self, a: str, x: int = 42, **kwargs):
              super().__init__(x=x, a=-1, raw_a=a, **kwargs)
  
      params = Params({"type": "b", "a": "123"})
      # The param `x` should not be required as it has default value in `B`
      # The correct type of the param `a` should be inferred from `B` as well.
      instance = BaseClass.from_params(params)
      assert instance.x == 42
      assert instance.a == -1
      assert len(instance.rest) == 1
      assert type(instance.rest["raw_a"]) == str
      assert instance.rest["raw_a"] == "123"
  
imports: from typing import Dict, Iterable, List, Mapping, Optional, Set, Tuple, Union
  import pytest
  import torch
  from allennlp.common import Lazy, Params, Registrable
  from allennlp.common.from_params import FromParams, takes_arg, remove_optional, create_kwargs
  from allennlp.common.testing import AllenNlpTestCase
  from allennlp.data import DataLoader, DatasetReader, Tokenizer
  from allennlp.models import Model
  from allennlp.models.archival import load_archive
  from allennlp.common.checks import ConfigurationError
label_desc: Use image node_id 23 for calling the TestFromParams obj's underlying member method code with example usage: obj.test_only_infer_superclass_params_if_unknown() without return types