code: def get_best_val_models(
      leaderboard: pd.DataFrame,
  ) -> Tuple[str, str, bool]:
      """
      Given a leaderboard from `predictor.leaderboard(test_data)`, determine the best model based on validation score that is affected by stacked overfitting,
      the best model that is not affected, and whether any affected models exist at all.
  
      Parameters
      ----------
      leaderboard : pd.DataFrame
          A leaderboard produced by `predictor.leaderboard(test_data)`.
          The leaderboard needs to contain `score_val` and `model` as columns.
  
      Returns
      -------
      best_non_affected_model, str, name of the best model that is not affected.
      best_affected_model, str, name of the best model that is affected.
      affected_models_exist, bool, that specifics whether any affected models exist in the given leaderboard.
      """
      (
          non_affected,
          affected,
      ) = get_affected_stacked_overfitting_model_names(
          leaderboard=leaderboard
      )
  
      best_non_affected_model = (
          leaderboard[leaderboard["model"].isin(non_affected)]
          .sort_values(by="score_val", ascending=False)
          .iloc[0]
          .loc["model"]
      )
  
      affected_models_exist = len(affected) > 0
      best_affected_model = None
      if affected_models_exist:
          best_affected_model = (
              leaderboard[leaderboard["model"].isin(affected)]
              .sort_values(by="score_val", ascending=False)
              .iloc[0]
              .loc["model"]
          )
  
      return (
          best_non_affected_model,
          best_affected_model,
          affected_models_exist,
      )
  
imports: import logging
  from typing import List, Tuple
  import pandas
label_desc: Use image node_id 2 for calling a global function with example usage: get_best_val_models(leaderboard) and returns: best_non_affected_model,  best_affected_model,  affected_models_exist