class_docstr: Base class for NAS strategies.
  
  To explore a space with a strategy, use::
  
      strategy = MyStrategy()
      strategy(model_space, engine)
  
  The strategy has a :meth:`run` method, that defines the process of exploring a NAS space.
  
  Strategy is stateful. It might store information of the current :meth:`initialize` and :meth:`run` as member attributes.
  We do not allow :meth:`run` a strategy twice with same, or different model spaces.
  
  Subclass should override :meth:`_initialize` and :meth:`_run`,
  as well as :meth:`state_dict` and :meth:`load_state_dict` for checkpointing.
class_docstr_tok: ["Base","class","for","NAS","strategies",".","To","explore","a","space","with","a","strategy",",","use",":",":","strategy","=","MyStrategy","(",")","strategy","(","model_space",",","engine",")","The","strategy","has","a",":","meth",":","`","run","`","method",",","that","defines","the","process","of","exploring","a","NAS","space",".","Strategy","is","stateful",".","It","might","store","information","of","the","current",":","meth",":","`","initialize","`","and",":","meth",":","`","run","`","as","member","attributes",".","We","do","not","allow",":","meth",":","`","run","`","a","strategy","twice","with","same",",","or","different","model","spaces",".","Subclass","should","override",":","meth",":","`","_initialize","`","and",":","meth",":","`","_run","`",",","as","well","as",":","meth",":","`","state_dict","`","and",":","meth",":","`","load_state_dict","`","for","checkpointing","."]
docstr: Clean up the strategy.
  
  This method is called when :meth:`run` finishes.
  
  Subclass can optionally override this to unregister itself from the engine,
  so that it won't get erroneously notified when the engine turns to running models submitted by another strategy.
  Since strategy can't run twice, by design it shouldn't register the callbacks again.
  
  To make APIs like :meth:`list_models` continue to work, we generally don't recommend "unset" the engines here.
docstr_tok: ["Clean","up","the","strategy",".","This","method","is","called","when",":","meth",":","`","run","`","finishes",".","Subclass","can","optionally","override","this","to","unregister","itself","from","the","engine",",","so","that","it","wo","n't","get","erroneously","notified","when","the","engine","turns","to","running","models","submitted","by","another","strategy",".","Since","strategy","ca","n't","run","twice",",","by","design","it","should","n't","register","the","callbacks","again",".","To","make","APIs","like",":","meth",":","`","list_models","`","continue","to","work",",","we","generally","do","n't","recommend","``","unset","''","the","engines","here","."]
code: def _cleanup(self) -> None:
      """Clean up the strategy.
  
      This method is called when :meth:`run` finishes.
  
      Subclass can optionally override this to unregister itself from the engine,
      so that it won't get erroneously notified when the engine turns to running models submitted by another strategy.
      Since strategy can't run twice, by design it shouldn't register the callbacks again.
  
      To make APIs like :meth:`list_models` continue to work, we generally don't recommend "unset" the engines here.
      """
      _logger.debug("Strategy %r cleaned up.", self)
  
imports: from __future__ import annotations
  import logging
  import time
  from enum import Enum
  from typing import Iterator, cast
  from nni.nas.execution import ExecutionEngine
  from nni.nas.space import ExecutableModelSpace, ModelStatus
  from nni.typehint import TrialMetric
label_desc: Use image node_id 12 for calling the Strategy obj's underlying member method code with example usage: obj._cleanup() without return types