code: def get_generation_strategy_sqa_reduced_state(
      gs_id: int, decoder: Decoder
  ) -> SQAGenerationStrategy:
      """Obtains most of the SQLAlchemy generation strategy object from DB."""
      gs_sqa_class = cast(
          Type[SQAGenerationStrategy],
          decoder.config.class_to_sqa_class[GenerationStrategy],
      )
      gr_sqa_class = cast(
          Type[SQAGeneratorRun],
          decoder.config.class_to_sqa_class[GeneratorRun],
      )
  
      gs_sqa = get_generation_strategy_sqa(
          gs_id=gs_id,
          decoder=decoder,
          query_options=[
              lazyload("generator_runs.parameters"),
              lazyload("generator_runs.parameter_constraints"),
              lazyload("generator_runs.metrics"),
              defaultload(gs_sqa_class.generator_runs).defer(
                  "model_kwargs"
              ),
              defaultload(gs_sqa_class.generator_runs).defer(
                  "bridge_kwargs"
              ),
              defaultload(gs_sqa_class.generator_runs).defer(
                  "model_state_after_gen"
              ),
              defaultload(gs_sqa_class.generator_runs).defer(
                  "gen_metadata"
              ),
          ],
      )
  
      # Load full last generator run (including model state), for generation
      # strategy restoration
      if gs_sqa.generator_runs:
          last_generator_run_id = gs_sqa.generator_runs[-1].id
          with session_scope() as session:
              last_gr_sqa = (
                  session.query(gr_sqa_class)
                  .filter_by(id=last_generator_run_id)
                  .one_or_none()
              )
  
          # Swap last generator run with no state for a generator run with
          # state.
          gs_sqa.generator_runs[
              len(gs_sqa.generator_runs) - 1
          ] = not_none(last_gr_sqa)
  
      return gs_sqa
  
imports: from math import ceil
  from typing import Any, cast, Dict, List, Optional, Type
  from ax.core.experiment import Experiment
  from ax.core.generator_run import GeneratorRun
  from ax.core.metric import Metric
  from ax.core.trial import Trial
  from ax.exceptions.core import ExperimentNotFoundError, ObjectNotFoundError
  from ax.modelbridge.generation_strategy import GenerationStrategy
  from ax.storage.sqa_store.db import session_scope
  from ax.storage.sqa_store.decoder import Decoder
  from ax.storage.sqa_store.reduced_state import get_query_options_to_defer_immutable_duplicates, get_query_options_to_defer_large_model_cols
  from ax.storage.sqa_store.sqa_classes import SQAExperiment, SQAGenerationStrategy, SQAGeneratorRun, SQATrial
  from ax.storage.sqa_store.sqa_config import SQAConfig
  from ax.utils.common.constants import Keys
  from ax.utils.common.typeutils import checked_cast, not_none
  from sqlalchemy.orm import defaultload, lazyload, noload
  from sqlalchemy.orm.exc import DetachedInstanceError
label_desc: Use image node_id 15 for calling a global function with example usage: get_generation_strategy_sqa_reduced_state(gs_id, decoder) and returns: gs_sqa