code: def test_early_stopping_with_unaligned_results(self) -> None:
      # test case 1
      exp = get_test_map_data_experiment(
          num_trials=5, num_fetches=3, num_complete=5
      )
      # manually "unalign" timestamps to simulate real-world scenario
      # where each curve reports results at different steps
      data = checked_cast(MapData, exp.fetch_data())
  
      unaligned_timestamps = [
          0,
          1,
          4,
          1,
          2,
          3,
          1,
          3,
          4,
          0,
          1,
          2,
          0,
          2,
          4,
      ]
      data.map_df.loc[
          data.map_df["metric_name"] == "branin_map", "timestamp"
      ] = unaligned_timestamps
      exp.attach_data(data=data)
  
      """
          Dataframe after interpolation:
                      0           1          2           3          4
          timestamp
          0          146.138620         NaN        NaN  143.375669  65.033535
          1          117.388086  113.057480  44.627226  115.168704  58.636359
          2          111.575393   90.815154  40.237365   98.060315  52.239184
          3          105.762700   77.324501  35.847504         NaN  48.359101
          4           99.950007         NaN  30.522333         NaN  44.479018
          """
      # We consider trials 0, 2, and 4 for early stopping at progression 4,
      #    and choose to stop trial 0.
      # We consider trial 1 for early stopping at progression 3, and
      #    choose to stop it.
      # We consider trial 3 for early stopping at progression 2, and
      #    choose to stop it.
      early_stopping_strategy = PercentileEarlyStoppingStrategy(
          percentile_threshold=50,
          min_curves=3,
          min_progression=0.1,
      )
      should_stop = _evaluate_early_stopping_with_df(
          early_stopping_strategy=early_stopping_strategy,
          experiment=exp,
          df=data.map_df,
      )
      self.assertEqual(set(should_stop), {0, 1, 3})
  
      # test case 2, where trial 3 has only 1 data point
      exp = get_test_map_data_experiment(
          num_trials=5, num_fetches=3, num_complete=5
      )
  
      # manually "unalign" timestamps to simulate real-world scenario
      # where each curve reports results at different steps
      data = checked_cast(MapData, exp.fetch_data())
      data.map_df.sort_values(
          by=["metric_name", "arm_name"], inplace=True
      )
      data.map_df.reset_index(drop=True, inplace=True)
  
      unaligned_timestamps = [
          0,
          1,
          4,
          1,
          2,
          3,
          1,
          3,
          4,
          0,
          1,
          2,
          0,
          2,
          4,
      ]
      data.map_df.loc[
          data.map_df["metric_name"] == "branin_map", "timestamp"
      ] = unaligned_timestamps
      # manually remove timestamps 1 and 2 for arm 3
      data.map_df.drop(
          [15, 16], inplace=True
      )  # TODO this wont work once we make map_df immutable (which we should)
      exp.attach_data(data=data)
  
      """
          Dataframe after interpolation:
                      0           1          2           3          4
          timestamp
          0          146.138620         NaN        NaN  143.375669  65.033535
          1          117.388086  113.057480  44.627226         NaN  58.636359
          2          111.575393   90.815154  40.237365         NaN  52.239184
          3          105.762700   77.324501  35.847504         NaN  48.359101
          4           99.950007         NaN  30.522333         NaN  44.479018
          """
  
      # We consider trials 0, 2, and 4 for early stopping at progression 4,
      #    and choose to stop trial 0.
      # We consider trial 1 for early stopping at progression 3, and
      #    choose to stop it.
      # We consider trial 3 for early stopping at progression 0, and
      #    choose not to stop it.
      early_stopping_strategy = PercentileEarlyStoppingStrategy(
          percentile_threshold=50,
          min_curves=3,
          min_progression=0.1,
      )
      should_stop = _evaluate_early_stopping_with_df(
          early_stopping_strategy=early_stopping_strategy,
          experiment=exp,
          df=data.map_df,
      )
      self.assertEqual(set(should_stop), {0, 1})
  
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 4 for calling the TestPercentileEarlyStoppingStrategy obj's underlying member method code with example usage: obj.test_early_stopping_with_unaligned_results() without return types