code: def _update_generation_strategy(
      generation_strategy: GenerationStrategy,
      generator_runs: List[GeneratorRun],
      encoder: Encoder,
      decoder: Decoder,
      batch_size: Optional[int] = None,
      reduce_state_generator_runs: bool = False,
  ) -> None:
      """Update generation strategy's current step and attach generator runs."""
      gs_sqa_class = encoder.config.class_to_sqa_class[
          GenerationStrategy
      ]
  
      gs_id = generation_strategy.db_id
      if gs_id is None:
          raise ValueError(
              "GenerationStrategy must be saved before being updated."
          )
  
      experiment_id = generation_strategy.experiment.db_id
      if experiment_id is None:
          raise ValueError(
              f"Experiment {generation_strategy.experiment.name} "
              "should be saved before generation strategy."
          )
  
      with session_scope() as session:
          session.query(gs_sqa_class).filter_by(id=gs_id).update(
              {
                  "curr_index": generation_strategy.current_step_index,
                  "experiment_id": experiment_id,
              }
          )
  
      # pyre-fixme[53]: Captured variable `gs_id` is not annotated.
      # pyre-fixme[3]: Return type must be annotated.
      def add_generation_strategy_id(sqa: SQAGeneratorRun):
          sqa.generation_strategy_id = gs_id
  
      # pyre-fixme[3]: Return type must be annotated.
      def generator_run_to_sqa_encoder(
          gr: GeneratorRun, weight: Optional[float] = None
      ):
          return encoder.generator_run_to_sqa(
              gr,
              weight=weight,
              reduced_state=reduce_state_generator_runs,
          )
  
      _bulk_merge_into_session(
          objs=generator_runs,
          encode_func=generator_run_to_sqa_encoder,
          decode_func=decoder.generator_run_from_sqa,
          decode_args_list=[
              {
                  "reduced_state": False,
                  "immutable_search_space_and_opt_config": False,
              }
              for _ in range(len(generator_runs))
          ],
          modify_sqa=add_generation_strategy_id,
          batch_size=batch_size,
      )
  
imports: import os
  from logging import Logger
  from typing import Any, Callable, Dict, List, Optional, Sequence, Union
  from ax.core.base_trial import BaseTrial
  from ax.core.experiment import Experiment
  from ax.core.generator_run import GeneratorRun
  from ax.core.metric import Metric
  from ax.core.outcome_constraint import ObjectiveThreshold, OutcomeConstraint
  from ax.core.runner import Runner
  from ax.exceptions.core import UserInputError
  from ax.exceptions.storage import SQADecodeError
  from ax.modelbridge.generation_strategy import GenerationStrategy
  from ax.storage.sqa_store.db import session_scope, SQABase
  from ax.storage.sqa_store.decoder import Decoder
  from ax.storage.sqa_store.encoder import Encoder
  from ax.storage.sqa_store.sqa_classes import SQAData, SQAGeneratorRun, SQAMetric, SQARunner, SQATrial
  from ax.storage.sqa_store.sqa_config import SQAConfig
  from ax.storage.sqa_store.utils import copy_db_ids
  from ax.utils.common.base import Base
  from ax.utils.common.logger import get_logger
  from ax.utils.common.typeutils import checked_cast, not_none
label_desc: Use image node_id 10 for calling a global function with example usage: _update_generation_strategy(generation_strategy, generator_runs, encoder, decoder, batch_size, reduce_state_generator_runs) and returns: encoder