code: def test_union(self):
      class A(FromParams):
          def __init__(self, a: Union[int, List[int]]) -> None:
              self.a = a
  
      class B(FromParams):
          def __init__(self, b: Union[A, List[A]]) -> None:
              # Really you would want to be sure that `self.b` has a consistent type, but for
              # this test we'll ignore that.
              self.b = b
  
      params = Params({"a": 3})
      a = A.from_params(params)
      assert a.a == 3
  
      params = Params({"a": [3, 4, 5]})
      a = A.from_params(params)
      assert a.a == [3, 4, 5]
  
      params = Params({"b": {"a": 3}})
      b = B.from_params(params)
      assert isinstance(b.b, A)
      assert b.b.a == 3
  
      params = Params({"b": [{"a": 3}, {"a": [4, 5]}]})
      b = B.from_params(params)
      assert isinstance(b.b, list)
      assert b.b[0].a == 3
      assert b.b[1].a == [4, 5]
  
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 9 for calling the TestFromParams obj's underlying member method code with example usage: obj.test_union() without return types