code: def test_extras_for_custom_classes(self):
      from allennlp.common.registrable import Registrable
  
      class BaseClass(Registrable):
          pass
  
      class BaseClass2(Registrable):
          pass
  
      @BaseClass.register("A")
      class A(BaseClass):
          def __init__(self, a: int, b: int, val: str) -> None:
              self.a = a
              self.b = b
              self.val = val
  
          def __hash__(self):
              return self.b
  
          def __eq__(self, other):
              return self.b == other.b
  
          @classmethod
          def from_params(cls, params: Params, a: int, **extras) -> "A":  # type: ignore
              # A custom from params
              b = params.pop_int("b")
              val = params.pop("val", "C")
              params.assert_empty(cls.__name__)
              return cls(a=a, b=b, val=val)
  
      @BaseClass2.register("B")
      class B(BaseClass2):
          def __init__(self, c: int, b: int) -> None:
              self.c = c
              self.b = b
  
          @classmethod
          def from_params(cls, params: Params, c: int, **extras) -> "B":  # type: ignore
              b = params.pop_int("b")
              params.assert_empty(cls.__name__)
              return cls(c=c, b=b)
  
      @BaseClass.register("E")
      class E(BaseClass):
          def __init__(self, m: int, n: int) -> None:
              self.m = m
              self.n = n
  
          @classmethod
          def from_params(cls, params: Params, **extras2) -> "E":  # type: ignore
              m = params.pop_int("m")
              params.assert_empty(cls.__name__)
              n = extras2["n"]
              return cls(m=m, n=n)
  
      class C:
          pass
  
      @BaseClass.register("D")
      class D(BaseClass):
          def __init__(
              self,
              arg1: List[BaseClass],
              arg2: Tuple[BaseClass, BaseClass2],
              arg3: Dict[str, BaseClass],
              arg4: Set[BaseClass],
              arg5: List[BaseClass],
          ) -> None:
              self.arg1 = arg1
              self.arg2 = arg2
              self.arg3 = arg3
              self.arg4 = arg4
              self.arg5 = arg5
  
      vals = [1, 2, 3]
      params = Params(
          {
              "type": "D",
              "arg1": [
                  {"type": "A", "b": vals[0]},
                  {"type": "A", "b": vals[1]},
                  {"type": "A", "b": vals[2]},
              ],
              "arg2": [
                  {"type": "A", "b": vals[0]},
                  {"type": "B", "b": vals[0]},
              ],
              "arg3": {
                  "class_1": {"type": "A", "b": vals[0]},
                  "class_2": {"type": "A", "b": vals[1]},
              },
              "arg4": [
                  {"type": "A", "b": vals[0], "val": "M"},
                  {"type": "A", "b": vals[1], "val": "N"},
                  {"type": "A", "b": vals[1], "val": "N"},
              ],
              "arg5": [{"type": "E", "m": 9}],
          }
      )
      extra = C()
      tval1 = 5
      tval2 = 6
      d = BaseClass.from_params(
          params=params, extra=extra, a=tval1, c=tval2, n=10
      )
  
      # Tests for List # Parameters
      assert len(d.arg1) == len(vals)
      assert isinstance(d.arg1, list)
      assert isinstance(d.arg1[0], A)
      assert all(x.b == y for x, y in zip(d.arg1, vals))
      assert all(x.a == tval1 for x in d.arg1)
  
      # Tests for Tuple
      assert isinstance(d.arg2, tuple)
      assert isinstance(d.arg2[0], A)
      assert isinstance(d.arg2[1], B)
      assert d.arg2[0].a == tval1
      assert d.arg2[1].c == tval2
      assert d.arg2[0].b == d.arg2[1].b == vals[0]
  
      # Tests for Dict
      assert isinstance(d.arg3, dict)
      assert isinstance(d.arg3["class_1"], A)
      assert d.arg3["class_1"].a == d.arg3["class_2"].a == tval1
      assert d.arg3["class_1"].b == vals[0]
      assert d.arg3["class_2"].b == vals[1]
  
      # Tests for Set
      assert isinstance(d.arg4, set)
      assert len(d.arg4) == 2
      assert any(x.val == "M" for x in d.arg4)
      assert any(x.val == "N" for x in d.arg4)
  
      # Tests for custom extras parameters
      assert isinstance(d.arg5, list)
      assert isinstance(d.arg5[0], E)
      assert d.arg5[0].m == 9
      assert d.arg5[0].n == 10
  
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 7 for calling the TestFromParams obj's underlying member method code with example usage: obj.test_extras_for_custom_classes() and returns: self, unknown, cls, cls, cls