code: def test_mock_trial_api(caplog):
      from nni.nas.space import RawFormatModelSpace, BaseModelSpace
  
      class DummyModelSpace(BaseModelSpace):
          def check_contains(self, sample):
              return None
  
          def leaf_mutables(self, is_leaf):
              yield from ()
  
          def freeze(self, sample):
              return self
  
      def foo(model):
          import nni
  
          nni.report_intermediate_result(0.5)
          assert "Intermediate metric: 0.5" in caplog.text
          nni.report_final_result(0.6)
          assert "Final metric: 0.6" in caplog.text
  
      space = DummyModelSpace()
      space_cvt = RawFormatModelSpace.from_model(space)
      model = space_cvt.random()
      evaluator = FunctionalEvaluator(foo)
  
      with pytest.raises(TypeError, match="ExecutableModelSpace"):
          m = model.executable_model()
          with evaluator.mock_runtime(m):
              evaluator.evaluate(m)
  
      with evaluator.mock_runtime(model):
          import nni
  
          assert nni.get_current_parameter() == model
          evaluator.evaluate(model.executable_model())
          assert "[Mock] Final" in caplog.text
  
      assert nni.get_current_parameter() is None
  
imports: import re
  import sys
  import pytest
  import nni
  import nni.trial
  import torch
  import pytorch_lightning
  from nni.mutable import Categorical, Numerical, SampleValidationError
  from nni.mutable.mutable import _mutable_equal
  from nni.nas.evaluator import FunctionalEvaluator
  from nni.nas.evaluator.pytorch import Classification, Lightning, DataLoader, Trainer, LightningModule
  from nni.nas.evaluator.evaluator import FrozenEvaluator
  from torch import nn
  from torch.utils.data import TensorDataset
label_desc: Use image node_id 11 for calling a global function with example usage: test_mock_trial_api(caplog) and returns: None, self