class_docstr: Tests saving/loading functionality of WithDBSettingsBase class.
class_docstr_tok: ["Tests","saving\/loading","functionality","of","WithDBSettingsBase","class","."]
code: def test_update_reduced_state_generator_runs(self) -> None:
      (
          experiment,
          generation_strategy,
      ) = self.init_experiment_and_generation_strategy(
          save_generation_strategy=True
      )
  
      trials = [experiment.new_trial() for _ in range(5)]
      grs = []
      for t in trials:
          gr = generation_strategy.gen(experiment)
          grs.append(gr)
          t.add_generator_run(gr)
  
      self.with_db_settings._save_or_update_trials_and_generation_strategy_if_possible(  # noqa E501
          experiment=experiment,
          # pyre-fixme[6]: For 2nd param expected `List[BaseTrial]` but got
          #  `List[Trial]`.
          trials=trials,
          generation_strategy=generation_strategy,
          new_generator_runs=grs,
          reduce_state_generator_runs=True,
      )
  
      loaded_experiment = _load_experiment(
          experiment.name,
          decoder=self.with_db_settings.db_settings.decoder,
      )
  
      # Only the last trial's generator run should have large model attributes
      for idx, trial in loaded_experiment.trials.items():
          for key in [f"_{attr.key}" for attr in GR_LARGE_MODEL_ATTRS]:
              if idx < len(loaded_experiment.trials) - 1:
                  # pyre-fixme[16]: `BaseTrial` has no attribute `generator_run`.
                  self.assertIsNone(getattr(trial.generator_run, key))
              else:
                  self.assertIsNotNone(
                      getattr(trial.generator_run, key)
                  )
  
      loaded_generation_strategy = (
          _load_generation_strategy_by_experiment_name(
              experiment.name,
              decoder=self.with_db_settings.db_settings.decoder,
          )
      )
  
      # Only the last generator run should have large model attributes
      for idx, gr in enumerate(
          loaded_generation_strategy._generator_runs
      ):
          for key in [f"_{attr.key}" for attr in GR_LARGE_MODEL_ATTRS]:
              if (
                  idx
                  < len(loaded_generation_strategy._generator_runs) - 1
              ):
                  self.assertIsNone(getattr(gr, key))
              else:
                  self.assertIsNotNone(getattr(gr, key))
  
imports: import random
  import string
  from typing import Tuple
  from unittest.mock import patch
  from ax.core.base_trial import TrialStatus
  from ax.core.experiment import Experiment
  from ax.modelbridge.generation_strategy import GenerationStrategy
  from ax.service.utils.with_db_settings_base import WithDBSettingsBase
  from ax.storage.sqa_store.db import init_test_engine_and_session_factory
  from ax.storage.sqa_store.load import _load_experiment, _load_generation_strategy_by_experiment_name
  from ax.storage.sqa_store.reduced_state import GR_LARGE_MODEL_ATTRS
  from ax.storage.sqa_store.save import _save_experiment, _save_generation_strategy, _save_or_update_trials
  from ax.storage.sqa_store.structs import DBSettings
  from ax.utils.common.testutils import TestCase
  from ax.utils.testing.core_stubs import get_experiment, get_generator_run, SpecialGenerationStrategy
  from ax.utils.testing.modeling_stubs import get_generation_strategy
label_desc: Use image node_id 16 for calling the TestWithDBSettingsBase obj's underlying member method code with example usage: obj.test_update_reduced_state_generator_runs() without return types