code: def get_last_generations(model: Fedot):
      """This function takes final individual and last generation from fitted Fedot-class object."""
  
      # TODO: in the future we should take here a copy. The problem is that Individual object is not copied.
      generations = model.history.generations
      if len(generations) < 2:
          raise ValueError(
              "Model has < 2 generations. Please fit model and try again."
          )
      sorted_final_generation = sorted(
          generations[-1], key=lambda x: x.fitness.value
      )
      return {
          "final_choice": sorted_final_generation[0],
          "last_generation": generations[-2],
      }
  
file_path: FEDOT/fedot/core/pipelines/prediction_intervals/utils.py
imports: import numpy
  from typing import List
  from fedot.core.pipelines.ts_wrappers import fitted_values
  from fedot.core.pipelines.pipeline import Pipeline
  from fedot import Fedot
  from fedot.core.data.data import InputData
  from golem.core.optimisers.opt_history_objects.individual import Individual
  from fedot.core.pipelines.prediction_intervals.params import PredictionIntervalsParams
  from fedot.core.pipelines.prediction_intervals.graph_distance import get_distance_between
label_desc: Use image node_id 3 for calling a global function with example usage: get_last_generations(model) and returns: dict