code: def test_invalid_default():
      # Ensure an invalid default value found in the PyTensor code only causes
      # a crash if it is not overridden by the user.
  
      root = _create_test_config()
  
      def validate(val):
          if val == "invalid":
              raise ValueError("Test-triggered")
  
      with pytest.raises(ValueError, match="Test-triggered"):
          # This should raise a ValueError because the default value is
          # invalid.
          root.add(
              "test__test_invalid_default_a",
              doc="unittest",
              configparam=ConfigParam("invalid", validate=validate),
              in_c_key=False,
          )
  
      root._flags_dict["test__test_invalid_default_b"] = "ok"
      # This should succeed since we defined a proper value, even
      # though the default was invalid.
      root.add(
          "test__test_invalid_default_b",
          doc="unittest",
          configparam=ConfigParam("invalid", validate=validate),
          in_c_key=False,
      )
  
      # Check that the flag has been removed
      assert "test__test_invalid_default_b" not in root._flags_dict
  
imports: import configparser
  import io
  import pickle
  import pytest
  from pytensor import configdefaults, configparser
  from pytensor.configdefaults import short_platform
  from pytensor.configparser import ConfigParam
label_desc: Use image node_id 2 for calling a global function with example usage: test_invalid_default() without return types