code: def test_multiple_evaluation_messy(named_model_space):
      name, model_space = named_model_space
      mock_strategy = MockStrategy(auto_check=False)
      strategy = Chain(mock_strategy, MultipleEvaluation(3))
      engine = SequentialExecutionEngine(
          max_model_count=30, continue_on_failure=True
      )
  
      import nni
  
      def wrap(fn):
          def wrapper(*args, **kwargs):
              if random.random() < 0.5:
                  nni.report_intermediate_result(0.0)
              fn(*args, **kwargs)
              if random.random() < 0.3:
                  nni.report_final_result(1.0)
              if random.random() < 0.3:
                  raise RuntimeError("failed")
  
          return wrapper
  
      model_space.evaluator.function = wrap(
          model_space.evaluator.function
      )
  
      strategy(model_space, engine)
      assert len(list(strategy.list_models(sort=False))) * 3 == len(
          list(engine.list_models())
      )
  
      for model in strategy.list_models(sort=False):
          assert 1 <= len(model.metrics.intermediates) <= 2
          assert (
              model.metrics.intermediates
              == mock_strategy._check_intermediate_events[model]
          )
          assert (
              model.metrics.final
              == mock_strategy._check_final_events[model][-1]
          )
          assert [model.status] == mock_strategy._check_status_events[
              model
          ]
          assert model.status in [
              ModelStatus.Trained,
              ModelStatus.Failed,
          ]
  
imports: import random
  from collections import defaultdict, Counter
  import pytest
  from nni.mutable import SampleValidationError
  from nni.nas.execution import SequentialExecutionEngine
  from nni.nas.space import ModelStatus
  from nni.nas.strategy import Random, RegularizedEvolution, PolicyBasedRL, GridSearch, Strategy
  from nni.nas.strategy.base import StrategyStatus
  from nni.nas.strategy.middleware import Filter, Chain, Deduplication, FailureHandler, MultipleEvaluation
  from .test_sanity import named_model_space, engine, naive_policy
label_desc: Use image node_id 10 for calling a global function with example usage: test_multiple_evaluation_messy(named_model_space) and returns: wrapper