code: def get_one_batch_of_trials(
      ax_client: AxClient,
      parallelism: Tuple[int, int],
      num_trials_so_far: int,
      num_max_trials_to_do: int,
  ) -> TrialBatch:
      """Returns a TrialBatch that contains a list of trials that can be
      run in parallel. TrialBatch also flags if the search space is exhausted.
      """
  
      is_search_space_exhausted = False
      # Ax throws an exception if the search space is exhausted. We catch
      # the exception and set the flag to True
      (num_trials, max_parallelism_setting) = parallelism
      if max_parallelism_setting == -1:
          # Special case, we can group all the trials into one batch
          max_parallelism_setting = num_trials - num_trials_so_far
  
          if num_trials == -1:
              # This is a special case where we can run as many trials in parallel as we want.
              # Given that num_trials is also -1, we can run all the trials in parallel.
              max_parallelism_setting = num_max_trials_to_do
  
      list_of_trials = []
      for _ in range(max_parallelism_setting):
          try:
              parameters, trial_index = ax_client.get_next_trial()
              list_of_trials.append(
                  Trial(
                      overrides=map_params_to_arg_list(
                          params=parameters
                      ),
                      trial_index=trial_index,
                  )
              )
          except SearchSpaceExhausted:
              is_search_space_exhausted = True
              break
  
      return TrialBatch(
          list_of_trials=list_of_trials,
          is_search_space_exhausted=is_search_space_exhausted,
      )
  
imports: import logging
  from dataclasses import dataclass
  from typing import Any, Dict, Iterable, List, Mapping, Optional, Tuple, Union
  from ax.core import types
  from ax.exceptions.core import SearchSpaceExhausted
  from ax.service.ax_client import AxClient
  from hydra.core.override_parser.overrides_parser import OverridesParser
  from hydra.core.override_parser.types import IntervalSweep, Override, Transformer
  from hydra.core.plugins import Plugins
  from hydra.plugins.launcher import Launcher
  from hydra.plugins.sweeper import Sweeper
  from hydra.types import HydraContext, TaskFunction
  from omegaconf import DictConfig, OmegaConf
  from ._earlystopper import EarlyStopper
  from .config import AxConfig, ClientConfig, ExperimentConfig
label_desc: Use image node_id 3 for calling a global function with example usage: get_one_batch_of_trials(ax_client, parallelism, num_trials_so_far, num_max_trials_to_do) and returns: TrialBatch