code: def test_union_of_castable_types(self):
      class IntFloat(FromParams):
          def __init__(self, a: Union[int, float]) -> None:
              self.a = a
  
      class FloatInt(FromParams):
          def __init__(self, a: Union[float, int]) -> None:
              self.a = a
  
      float_param_str = '{"a": 1.0}'
      int_param_str = '{"a": 1}'
      import json
  
      for expected_type, param_str in [
          (int, int_param_str),
          (float, float_param_str),
      ]:
          for cls in [IntFloat, FloatInt]:
              c = cls.from_params(Params(json.loads(param_str)))
              assert type(c.a) == expected_type
  
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 11 for calling the TestFromParams obj's underlying member method code with example usage: obj.test_union_of_castable_types() without return types