code: def get_early_stopping_generations(
      input_params: ApiParams, log: LoggerAdapter
  ) -> Dict[str, Optional[int]]:
      """Get number of early stopping generations depending on timeout."""
      # If early_stopping_generations is not specified,
      # than estimate it as in time-based manner as: 0.33 * composing_timeout.
      # The minimal number of generations is 5.
      early_stopping_iterations = None
      if "early_stopping_iterations" not in input_params:
          if input_params.timeout:
              depending_on_timeout = int(input_params.timeout / 3)
              early_stopping_iterations = (
                  depending_on_timeout
                  if depending_on_timeout > 5
                  else 5
              )
              log.info(
                  f"early_stopping_iterations was set to {early_stopping_iterations}"
              )
      return {"early_stopping_iterations": early_stopping_iterations}
  
imports: from golem.core.log import LoggerAdapter
  from typing import Dict, Optional
  from fedot.api.api_utils.params import ApiParams
  from fedot.core.data.data import InputData
label_desc: Use image node_id 3 for calling a global function with example usage: get_early_stopping_generations(input_params, log) and returns: dict