code: def test_deduplication_replay(named_model_space, engine):
      name, model_space = named_model_space
  
      strategy = Chain(
          MockStrategy(), Deduplication("replay", retain_history=True)
      )
      strategy(model_space, engine)
      assert len(engine.list_models()) < len(
          list(strategy.list_models())
      )
  
      for model in engine.list_models():
          for m in strategy.list_models():
              if model.sample == m.sample:
                  assert (
                      model.metrics.intermediates
                      == m.metrics.intermediates
                  )
                  assert model.metrics.final == m.metrics.final
                  assert model.status == m.status
                  assert m.status != ModelStatus.Invalid
  
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 5 for calling a global function with example usage: test_deduplication_replay(named_model_space, engine) without return types