code: def test_infer_and_cast(self):
      lots_of_strings = {
          "a": ["10", "1.3", "true"],
          "b": {"x": 10, "y": "20.1", "z": "other things"},
          "c": "just a string",
      }
  
      casted = {
          "a": [10, 1.3, True],
          "b": {"x": 10, "y": 20.1, "z": "other things"},
          "c": "just a string",
      }
  
      assert infer_and_cast(lots_of_strings) == casted
  
      contains_bad_data = {"x": 10, "y": int}
      with pytest.raises(ValueError, match="cannot infer type"):
          infer_and_cast(contains_bad_data)
  
      params = Params(lots_of_strings)
  
      assert params.as_dict() == lots_of_strings
      assert params.as_dict(infer_type_and_cast=True) == casted
  
imports: import json
  import os
  import re
  from collections import OrderedDict
  import pytest
  from allennlp.common.checks import ConfigurationError
  from allennlp.common.params import infer_and_cast, Params, remove_keys_from_params, with_overrides
  from allennlp.common.testing import AllenNlpTestCase
label_desc: Use image node_id 14 for calling the TestParams obj's underlying member method code with example usage: obj.test_infer_and_cast() without return types