code: def test_cross_validate_with_GP_model(
      self, mock_cv: Mock, mock_diagnostics: Mock
  ) -> None:
      mock_enum = Mock()
      fake_mb = MagicMock()
      fake_mb._process_and_transform_data = MagicMock(
          return_value=(None, None)
      )
      mock_enum.return_value = fake_mb
      ms = ModelSpec(
          model_enum=mock_enum,
          model_cv_kwargs={"test_key": "test-value"},
      )
      ms.fit(
          experiment=self.experiment,
          data=self.experiment.trials[0].fetch_data(),
      )
      cv_results, cv_diagnostics = ms.cross_validate()
      mock_cv.assert_called_with(model=fake_mb, test_key="test-value")
      mock_diagnostics.assert_called_with(["fake-cv-result"])
  
      self.assertIsNotNone(cv_results)
      self.assertIsNotNone(cv_diagnostics)
  
      with self.subTest("it caches CV results"):
          mock_cv.reset_mock()
          mock_diagnostics.reset_mock()
  
          cv_results, cv_diagnostics = ms.cross_validate()
  
          self.assertIsNotNone(cv_results)
          self.assertIsNotNone(cv_diagnostics)
          mock_cv.assert_not_called()
          mock_diagnostics.assert_not_called()
  
      with self.subTest("fit clears the CV cache"):
          mock_cv.reset_mock()
          mock_diagnostics.reset_mock()
  
          ms.fit(
              experiment=self.experiment,
              data=self.experiment.trials[0].fetch_data(),
          )
          cv_results, cv_diagnostics = ms.cross_validate()
  
          self.assertIsNotNone(cv_results)
          self.assertIsNotNone(cv_diagnostics)
          mock_cv.assert_called_with(
              model=fake_mb, test_key="test-value"
          )
          mock_diagnostics.assert_called_with(["fake-cv-result"])
  
imports: import warnings
  from unittest import mock
  from unittest.mock import MagicMock, Mock, patch
  from ax.core.observation import ObservationFeatures
  from ax.exceptions.core import UserInputError
  from ax.modelbridge.factory import get_sobol
  from ax.modelbridge.model_spec import FactoryFunctionModelSpec, ModelSpec
  from ax.modelbridge.modelbridge_utils import extract_search_space_digest
  from ax.modelbridge.registry import Models
  from ax.utils.common.testutils import TestCase
  from ax.utils.testing.core_stubs import get_branin_experiment
  from ax.utils.testing.mock import fast_botorch_optimize
label_desc: Use image node_id 4 for calling the ModelSpecTest obj's underlying member method code with example usage: obj.test_cross_validate_with_GP_model(mock_cv, mock_diagnostics) without return types