class_docstr: Class that contains methods for storing an Ax experiment to SQLAlchemy.
  
  Instantiate with an instance of Config to customize the functionality.
  For even more flexibility, create a subclass.
  
  Attributes:
      config: Metadata needed to save and load an experiment to SQLAlchemy.
class_docstr_tok: ["Class","that","contains","methods","for","storing","an","Ax","experiment","to","SQLAlchemy",".","Instantiate","with","an","instance","of","Config","to","customize","the","functionality",".","For","even","more","flexibility",",","create","a","subclass",".","Attributes",":","config",":","Metadata","needed","to","save","and","load","an","experiment","to","SQLAlchemy","."]
docstr: Convert an Ax `GenerationStrategy` to SQLAlchemy, preserving its state,
  so that the restored generation strategy can be resumed from the point
  at which it was interrupted and stored.
code: def generation_strategy_to_sqa(
      self,
      generation_strategy: GenerationStrategy,
      experiment_id: Optional[int],
      generator_run_reduced_state: bool = False,
  ) -> SQAGenerationStrategy:
      """Convert an Ax `GenerationStrategy` to SQLAlchemy, preserving its state,
      so that the restored generation strategy can be resumed from the point
      at which it was interrupted and stored.
      """
      # pyre-ignore[9]: Expected Base, but redeclared to `SQAGenerationStrategy`.
      gs_class: SQAGenerationStrategy = self.config.class_to_sqa_class[
          cast(Type[Base], GenerationStrategy)
      ]
      generator_runs_sqa = []
      node_based_strategy = generation_strategy.is_node_based
      for idx, gr in enumerate(generation_strategy._generator_runs):
          # Never reduce the state of the last generator run because that
          # generator run is needed to recreate the model when reloading the
          # generation strategy.
          is_last_gr = (
              idx == len(generation_strategy._generator_runs) - 1
          )
          reduced_state = generator_run_reduced_state and not is_last_gr
          gr_sqa = self.generator_run_to_sqa(
              gr, reduced_state=reduced_state
          )
          generator_runs_sqa.append(gr_sqa)
  
      # pyre-fixme[29]: `SQAGenerationStrategy` is not a function.
      gs_sqa = gs_class(
          id=generation_strategy.db_id,
          name=generation_strategy.name,
          steps=object_to_json(
              generation_strategy._steps,
              encoder_registry=self.config.json_encoder_registry,
              class_encoder_registry=self.config.json_class_encoder_registry,
          )
          if not node_based_strategy
          else [],
          curr_index=generation_strategy.current_step_index
          if not node_based_strategy
          else -1,
          generator_runs=generator_runs_sqa,
          experiment_id=experiment_id,
          nodes=object_to_json(
              generation_strategy._nodes,
              encoder_registry=self.config.json_encoder_registry,
              class_encoder_registry=self.config.json_class_encoder_registry,
          )
          if node_based_strategy
          else [],
          curr_node_name=generation_strategy.current_node_name,
      )
      return gs_sqa
  
imports: from enum import Enum
  from logging import Logger
  from typing import Any, cast, Dict, List, Optional, Tuple, Type
  from ax.core.arm import Arm
  from ax.core.base_trial import BaseTrial
  from ax.core.batch_trial import AbandonedArm, BatchTrial
  from ax.core.data import Data
  from ax.core.experiment import Experiment
  from ax.core.generator_run import GeneratorRun, GeneratorRunType
  from ax.core.metric import Metric
  from ax.core.multi_type_experiment import MultiTypeExperiment
  from ax.core.objective import MultiObjective, Objective, ScalarizedObjective
  from ax.core.optimization_config import MultiObjectiveOptimizationConfig, OptimizationConfig
  from ax.core.outcome_constraint import ObjectiveThreshold, OutcomeConstraint, ScalarizedOutcomeConstraint
  from ax.core.parameter import ChoiceParameter, FixedParameter, Parameter, RangeParameter
  from ax.core.parameter_constraint import OrderConstraint, ParameterConstraint, SumConstraint
  from ax.core.parameter_distribution import ParameterDistribution
  from ax.core.risk_measures import RiskMeasure
  from ax.core.runner import Runner
  from ax.core.search_space import RobustSearchSpace, SearchSpace
  from ax.core.trial import Trial
  from ax.exceptions.storage import SQAEncodeError
  from ax.modelbridge.generation_strategy import GenerationStrategy
  from ax.storage.json_store.encoder import object_to_json
  from ax.storage.sqa_store.sqa_classes import SQAAbandonedArm, SQAArm, SQAData, SQAExperiment, SQAGenerationStrategy, SQAGeneratorRun, SQAMetric, SQAParameter, SQAParameterConstraint, SQARunner, SQATrial
  from ax.storage.sqa_store.sqa_config import SQAConfig
  from ax.storage.utils import DomainType, MetricIntent, ParameterConstraintType
  from ax.utils.common.base import Base
  from ax.utils.common.constants import Keys
  from ax.utils.common.logger import get_logger
  from ax.utils.common.serialization import serialize_init_args
  from ax.utils.common.typeutils import checked_cast, not_none
label_desc: Use image node_id 25 for calling the Encoder obj's underlying member method code with example usage: obj.generation_strategy_to_sqa(generation_strategy, experiment_id, generator_run_reduced_state) and returns: gs_sqa