docstr: Test that the is_met method in MaxTrials works
docstr_tok: ["Test","that","the","is_met","method","in","MaxTrials","works"]
code: def test_max_trials_is_met(self) -> None:
      """Test that the is_met method in MaxTrials works"""
      experiment = get_branin_experiment()
      gs = GenerationStrategy(
          name="SOBOL::default",
          steps=[
              GenerationStep(
                  model=Models.SOBOL,
                  num_trials=4,
                  min_trials_observed=0,
                  enforce_num_trials=True,
              ),
              GenerationStep(
                  model=Models.SOBOL,
                  num_trials=4,
                  min_trials_observed=0,
                  enforce_num_trials=False,
              ),
              GenerationStep(
                  model=Models.SOBOL,
                  num_trials=-1,
                  max_parallelism=1,
              ),
          ],
      )
      gs.experiment = experiment
  
      # No trials yet, first step should fail
      self.assertFalse(
          gs._steps[0]
          .transition_criteria[0]
          .is_met(
              experiment=experiment,
              trials_from_node=gs._steps[0].trials_from_node,
          )
      )
  
      # After adding trials, should pass
      for _i in range(4):
          experiment.new_trial(gs.gen(experiment=experiment))
      self.assertTrue(
          gs._steps[0]
          .transition_criteria[0]
          .is_met(
              experiment=experiment,
              trials_from_node=gs._steps[0].trials_from_node,
          )
      )
  
      # Check not in statuses and only in statuses
      max_criterion_not_in_statuses = MaxTrials(
          threshold=2,
          block_gen_if_met=True,
          not_in_statuses=[TrialStatus.COMPLETED],
      )
      max_criterion_only_statuses = MaxTrials(
          threshold=2,
          block_gen_if_met=True,
          only_in_statuses=[
              TrialStatus.COMPLETED,
              TrialStatus.EARLY_STOPPED,
          ],
      )
      # experiment currently has 4 trials, but none of them are completed
      self.assertTrue(
          max_criterion_not_in_statuses.is_met(
              experiment, trials_from_node=gs._steps[0].trials_from_node
          )
      )
      self.assertFalse(
          max_criterion_only_statuses.is_met(
              experiment, trials_from_node=gs._steps[0].trials_from_node
          )
      )
  
      # set 3 of the 4 trials to status == completed
      for _idx, trial in experiment.trials.items():
          trial._status = TrialStatus.COMPLETED
          if _idx == 2:
              break
      self.assertTrue(
          max_criterion_only_statuses.is_met(
              experiment, trials_from_node=gs._steps[0].trials_from_node
          )
      )
      self.assertFalse(
          max_criterion_not_in_statuses.is_met(
              experiment, trials_from_node=gs._steps[0].trials_from_node
          )
      )
  
file_path: Ax/ax/modelbridge/tests/test_transition_criterion.py
imports: import logging
  from logging import Logger
  from unittest.mock import patch
  import pandas
  from ax.core.base_trial import TrialStatus
  from ax.core.data import Data
  from ax.modelbridge.generation_strategy import GenerationStep, GenerationStrategy
  from ax.modelbridge.registry import Models
  from ax.modelbridge.transition_criterion import MaxGenerationParallelism, MaxTrials, MinimumPreferenceOccurances, MinimumTrialsInStatus, MinTrials, TransitionCriterion
  from ax.utils.common.logger import get_logger
  from ax.utils.common.testutils import TestCase
  from ax.utils.testing.core_stubs import get_branin_experiment, get_experiment
label_desc: Use image node_id 4 for calling the TestTransitionCriterion obj's underlying member method code with example usage: obj.test_max_trials_is_met() without return types