code: def _update_top_pipeline(self):
          
          # Store the pipeline with the highest internal testing score
          if self._pareto_front:
              self._optimized_pipeline_score = -float('inf')
              for pipeline, pipeline_scores in zip(self._pareto_front.items, reversed(self._pareto_front.keys)):
                  if pipeline_scores.wvalues[1] > self._optimized_pipeline_score:
                      self._optimized_pipeline = pipeline
                      self._optimized_pipeline_score = pipeline_scores.wvalues[1]
  
              if not self._optimized_pipeline:
                  raise RuntimeError('There was an error in the TPOT optimization '
                                     'process. This could be because the data was '
                                     'not formatted properly, or because data for '
                                     'a regression problem was provided to the '
                                     'TPOTClassifier object. Please make sure you '
                                     'passed the data to TPOT correctly.')
              else:
                  pareto_front_wvalues = [pipeline_scores.wvalues[1] for pipeline_scores in self._pareto_front.keys]
                  if not self._last_optimized_pareto_front:
                      self._last_optimized_pareto_front = pareto_front_wvalues
                  elif self._last_optimized_pareto_front == pareto_front_wvalues:
                      self._last_optimized_pareto_front_n_gens += 1
                  else:
                      self._last_optimized_pareto_front = pareto_front_wvalues
                      self._last_optimized_pareto_front_n_gens = 0
          else:
              # If user passes CTRL+C in initial generation, self._pareto_front (halloffame) shoule be not updated yet.
              # need raise RuntimeError because no pipeline has been optimized
              raise RuntimeError('A pipeline has not yet been optimized. Please call fit() first.')
docs: Helper function to update the _optimized_pipeline field.