code: def _save_generation_strategy(
      generation_strategy: GenerationStrategy,
      encoder: Encoder,
      decoder: Decoder,
  ) -> int:
      # If the generation strategy has not yet generated anything, there will be no
      # experiment set on it.
      experiment = generation_strategy._experiment
      if experiment is None:
          experiment_id = None
      else:
          # Experiment was set on the generation strategy, so need to check whether
          # if has been saved and create a relationship b/w GS and experiment if so.
          experiment_id = experiment.db_id
          if experiment_id is None:
              raise ValueError(
                  f"Experiment {experiment.name} should be saved before "
                  "generation strategy."
              )
  
      _merge_into_session(
          obj=generation_strategy,
          encode_func=encoder.generation_strategy_to_sqa,
          decode_func=decoder.generation_strategy_from_sqa,
          encode_args={"experiment_id": experiment_id},
          decode_args={"experiment": experiment},
      )
  
      return not_none(generation_strategy.db_id)
  
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 4 for calling a global function with example usage: _save_generation_strategy(generation_strategy, encoder, decoder) and returns: not_none