code: def _evaluate_early_stopping_with_df(
      early_stopping_strategy: PercentileEarlyStoppingStrategy,
      experiment: Experiment,
      df: pd.DataFrame,
  ) -> Dict[int, Optional[str]]:
      """Helper function for testing PercentileEarlyStoppingStrategy
      on an arbitrary (MapData) df."""
      metric_to_aligned_means, _ = align_partial_results(
          df=df,
          progr_key="timestamp",
          metrics=["branin_map"],
      )
      aligned_means = metric_to_aligned_means["branin_map"]
      decisions = {
          trial_index: early_stopping_strategy.should_stop_trial_early(
              trial_index=trial_index,
              experiment=experiment,
              df=aligned_means,
              df_raw=df,
              map_key="timestamp",
              # pyre-fixme[16]: `Optional` has no attribute `objective`.
              minimize=experiment.optimization_config.objective.minimize,
          )
          for trial_index in set(experiment.trials.keys())
      }
      return {
          trial_index: reason
          for trial_index, (should_stop, reason) in decisions.items()
          if should_stop
      }
  
imports: from typing import Any, Dict, Optional, Set
  import numpy
  import pandas
  from ax.core.base_trial import TrialStatus
  from ax.core.experiment import Experiment
  from ax.core.map_data import MapData
  from ax.early_stopping.strategies import BaseEarlyStoppingStrategy, ModelBasedEarlyStoppingStrategy, PercentileEarlyStoppingStrategy, ThresholdEarlyStoppingStrategy
  from ax.early_stopping.strategies.logical import AndEarlyStoppingStrategy, OrEarlyStoppingStrategy
  from ax.early_stopping.utils import align_partial_results
  from ax.exceptions.core import UnsupportedError
  from ax.utils.common.testutils import TestCase
  from ax.utils.common.typeutils import checked_cast
  from ax.utils.testing.core_stubs import get_branin_arms, get_branin_experiment, get_branin_experiment_with_timestamp_map_metric, get_experiment_with_multi_objective, get_test_map_data_experiment
  from pyre_extensions import none_throws
label_desc: Use image node_id 1 for calling a global function with example usage: _evaluate_early_stopping_with_df(early_stopping_strategy, experiment, df) and returns: unknown