code: def test_trials_as_df(self) -> None:
      exp = get_branin_experiment()
      sobol_generation_strategy = GenerationStrategy(
          steps=[
              GenerationStep(model=Models.SOBOL, num_trials=2),
              GenerationStep(model=Models.SOBOL, num_trials=3),
          ]
      )
      # No trials yet, so the DF will be None.
      self.assertIsNone(sobol_generation_strategy.trials_as_df)
      # Now the trial should appear in the DF.
      trial = exp.new_trial(
          sobol_generation_strategy.gen(experiment=exp)
      )
      # pyre-fixme[16]: Optional type has no attribute `empty`.
      self.assertFalse(sobol_generation_strategy.trials_as_df.empty)
      self.assertEqual(
          # pyre-fixme[16]: Optional type has no attribute `head`.
          sobol_generation_strategy.trials_as_df.head()["Trial Status"][
              0
          ],
          "CANDIDATE",
      )
      # Changes in trial status should be reflected in the DF.
      trial._status = TrialStatus.RUNNING
      self.assertEqual(
          sobol_generation_strategy.trials_as_df.head()["Trial Status"][
              0
          ],
          "RUNNING",
      )
      # Check that rows are present for step 0 and 1 after moving to step 1
      for _i in range(3):
          # attach necessary trials to fill up the Generation Strategy
          trial = exp.new_trial(
              sobol_generation_strategy.gen(experiment=exp)
          )
      self.assertEqual(
          sobol_generation_strategy.trials_as_df.head()[
              "Generation Step"
          ][0],
          "GenerationStep_0",
      )
      self.assertEqual(
          sobol_generation_strategy.trials_as_df.head()[
              "Generation Step"
          ][2],
          "GenerationStep_1",
      )
  
      # construct the same GS as above but directly with nodes
      sobol_model_spec = ModelSpec(
          model_enum=Models.SOBOL,
          model_kwargs={},
          model_gen_kwargs={},
      )
      node_gs = GenerationStrategy(
          nodes=[
              GenerationNode(
                  node_name="sobol_2_trial",
                  model_specs=[sobol_model_spec],
                  transition_criteria=[
                      MaxTrials(
                          threshold=2,
                          not_in_statuses=[
                              TrialStatus.FAILED,
                              TrialStatus.ABANDONED,
                          ],
                          block_gen_if_met=True,
                          block_transition_if_unmet=True,
                          transition_to="sobol_3_trial",
                      )
                  ],
                  gen_unlimited_trials=False,
              ),
              GenerationNode(
                  node_name="sobol_3_trial",
                  model_specs=[sobol_model_spec],
                  transition_criteria=[
                      MaxTrials(
                          threshold=2,
                          not_in_statuses=[
                              TrialStatus.FAILED,
                              TrialStatus.ABANDONED,
                          ],
                          block_gen_if_met=True,
                          block_transition_if_unmet=True,
                          transition_to=None,
                      )
                  ],
                  gen_unlimited_trials=False,
              ),
          ]
      )
      self.assertIsNone(node_gs.trials_as_df)
      # Now the trial should appear in the DF.
      trial = exp.new_trial(node_gs.gen(experiment=exp))
  
      self.assertFalse(node_gs.trials_as_df.empty)
      self.assertEqual(
          node_gs.trials_as_df.head()["Trial Status"][0],
          "CANDIDATE",
      )
      # Changes in trial status should be reflected in the DF.
      trial._status = TrialStatus.RUNNING
      self.assertEqual(
          node_gs.trials_as_df.head()["Trial Status"][0], "RUNNING"
      )
      # Check that rows are present for step 0 and 1 after moving to step 1
      for _i in range(3):
          # attach necessary trials to fill up the Generation Strategy
          trial = exp.new_trial(node_gs.gen(experiment=exp))
      self.assertEqual(
          node_gs.trials_as_df.head()["Generation Node"][0],
          "sobol_2_trial",
      )
      self.assertEqual(
          node_gs.trials_as_df.head()["Generation Node"][2],
          "sobol_3_trial",
      )
  
imports: import logging
  from typing import cast, List
  from unittest import mock
  from unittest.mock import MagicMock, patch
  from ax.core.arm import Arm
  from ax.core.base_trial import TrialStatus
  from ax.core.experiment import Experiment
  from ax.core.generator_run import GeneratorRun
  from ax.core.observation import ObservationFeatures
  from ax.core.parameter import ChoiceParameter, FixedParameter, Parameter, ParameterType
  from ax.core.search_space import SearchSpace
  from ax.core.utils import get_pending_observation_features_based_on_trial_status
  from ax.exceptions.core import DataRequiredError, UnsupportedError, UserInputError
  from ax.exceptions.generation_strategy import GenerationStrategyCompleted, GenerationStrategyMisconfiguredException, GenerationStrategyRepeatedPoints, MaxParallelismReachedException
  from ax.modelbridge.discrete import DiscreteModelBridge
  from ax.modelbridge.factory import get_sobol
  from ax.modelbridge.generation_node import GenerationNode
  from ax.modelbridge.generation_strategy import GenerationStep, GenerationStrategy
  from ax.modelbridge.model_spec import ModelSpec
  from ax.modelbridge.random import RandomModelBridge
  from ax.modelbridge.registry import Cont_X_trans, MODEL_KEY_TO_MODEL_SETUP, Models
  from ax.modelbridge.torch import TorchModelBridge
  from ax.modelbridge.transition_criterion import MaxGenerationParallelism, MaxTrials, MinTrials
  from ax.models.random.sobol import SobolGenerator
  from ax.utils.common.equality import same_elements
  from ax.utils.common.mock import mock_patch_method_original
  from ax.utils.common.testutils import TestCase
  from ax.utils.common.typeutils import not_none
  from ax.utils.testing.core_stubs import get_branin_data, get_branin_experiment, get_choice_parameter, get_data, get_experiment_with_multi_objective, get_hierarchical_search_space_experiment
label_desc: Use image node_id 20 for calling the TestGenerationStrategy obj's underlying member method code with example usage: obj.test_trials_as_df() without return types