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: Initialize the strategy.
  
  This method should be called before :meth:`run` to initialize some states.
  
  Some strategies might even mutate the ``model_space``. They should return the mutated model space.
  
  :meth:`load_state_dict` can be called after :meth:`initialize` to restore the state of the strategy.
  
  Subclass override :meth:`_initialize` instead of this method.
docstr_tok: ["Initialize","the","strategy",".","This","method","should","be","called","before",":","meth",":","`","run","`","to","initialize","some","states",".","Some","strategies","might","even","mutate","the","``","model_space","``",".","They","should","return","the","mutated","model","space",".",":","meth",":","`","load_state_dict","`","can","be","called","after",":","meth",":","`","initialize","`","to","restore","the","state","of","the","strategy",".","Subclass","override",":","meth",":","`","_initialize","`","instead","of","this","method","."]
code: def initialize(
      self, model_space: ExecutableModelSpace, engine: ExecutionEngine
  ) -> ExecutableModelSpace:
      """Initialize the strategy.
  
      This method should be called before :meth:`run` to initialize some states.
  
      Some strategies might even mutate the ``model_space``. They should return the mutated model space.
  
      :meth:`load_state_dict` can be called after :meth:`initialize` to restore the state of the strategy.
  
      Subclass override :meth:`_initialize` instead of this method.
      """
      if self._status != StrategyStatus.EMPTY:
          raise RuntimeError("Strategy has already been initialized.")
      self._model_space = model_space
      self._engine = engine
      model_space = self._initialize(model_space, engine)
      self._status = StrategyStatus.INITIALIZED
      return model_space
  
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 8 for calling the Strategy obj's underlying member method code with example usage: obj.initialize(model_space, engine) and returns: model_space