class_docstr: Helper class providing methods for saving changes made to an experiment
  if `db_settings` property is set to a non-None value on the instance.
class_docstr_tok: ["Helper","class","providing","methods","for","saving","changes","made","to","an","experiment","if","`","db_settings","`","property","is","set","to","a","non-None","value","on","the","instance","."]
docstr: Saves new trials (and updates existing ones) on given experiment
  and updates the given generation strategy, if DB settings are set on
  this `WithDBSettingsBase` instance.
  
  Args:
      experiment: Experiment, on which to save new trials in DB.
      trials: Newly added or updated trials to save or update in DB.
      generation_strategy: Generation strategy to update in DB.
      new_generator_runs: Generator runs to add to generation strategy.
docstr_tok: ["Saves","new","trials","(","and","updates","existing","ones",")","on","given","experiment","and","updates","the","given","generation","strategy",",","if","DB","settings","are","set","on","this","`","WithDBSettingsBase","`","instance",".","Args",":","experiment",":","Experiment",",","on","which","to","save","new","trials","in","DB",".","trials",":","Newly","added","or","updated","trials","to","save","or","update","in","DB",".","generation_strategy",":","Generation","strategy","to","update","in","DB",".","new_generator_runs",":","Generator","runs","to","add","to","generation","strategy","."]
code: def _save_or_update_trials_and_generation_strategy_if_possible(
      self,
      experiment: Experiment,
      trials: List[BaseTrial],
      generation_strategy: GenerationStrategyInterface,
      new_generator_runs: List[GeneratorRun],
      reduce_state_generator_runs: bool = False,
  ) -> None:
      """Saves new trials (and updates existing ones) on given experiment
      and updates the given generation strategy, if DB settings are set on
      this `WithDBSettingsBase` instance.
  
      Args:
          experiment: Experiment, on which to save new trials in DB.
          trials: Newly added or updated trials to save or update in DB.
          generation_strategy: Generation strategy to update in DB.
          new_generator_runs: Generator runs to add to generation strategy.
      """
      logger.debug(f"Saving or updating {len(trials)} trials in DB.")
      self._save_or_update_trials_in_db_if_possible(
          experiment=experiment,
          trials=trials,
          reduce_state_generator_runs=reduce_state_generator_runs,
      )
      logger.debug(
          "Updating generation strategy in DB with "
          f"{len(new_generator_runs)} generator runs."
      )
      self._update_generation_strategy_in_db_if_possible(
          generation_strategy=generation_strategy,
          new_generator_runs=new_generator_runs,
          reduce_state_generator_runs=reduce_state_generator_runs,
      )
      return
  
imports: import re
  import time
  from logging import INFO, Logger
  from typing import Any, Dict, List, Optional, Tuple, Type
  from ax.core.base_trial import BaseTrial
  from ax.core.experiment import Experiment
  from ax.core.generation_strategy_interface import GenerationStrategyInterface
  from ax.core.generator_run import GeneratorRun
  from ax.exceptions.core import IncompatibleDependencyVersion, ObjectNotFoundError, UnsupportedError
  from ax.modelbridge.generation_strategy import GenerationStrategy
  from ax.utils.common.executils import retry_on_exception
  from ax.utils.common.logger import _round_floats_for_logging, get_logger
  from ax.utils.common.typeutils import not_none
label_desc: Use image node_id 9 for calling the WithDBSettingsBase obj's underlying member method code with example usage: obj._save_or_update_trials_and_generation_strategy_if_possible(experiment, trials, generation_strategy, new_generator_runs, reduce_state_generator_runs) without return types