code: def get_trial_mode(ensemble_spec, distillation_spec, trial_id):
      """Determines whether to bundle logits with Ensembler or Distiller.
  
      If distillation and ensembling are specified at the same time, checks pool
      sizes to see which phase this trial falls in. If the pool sizes are the same,
      then defaults to ENSEMBLE_SEARCH.
  
      Args:
        ensemble_spec: The spec defined in the Phoenix spec.
        distillation_spec: The spec defined in the Phoenix spec.
        trial_id: trial id.
  
      Returns:
        TrialMode
      """
  
      # Handle intermixed separately since there is no pool size
      if is_intermixed_ensemble_search(ensemble_spec):
          if has_distillation(distillation_spec):
              n = ensemble_spec.intermixed_search.try_ensembling_every
              # Immediately after an ensemble search trial, do a distillation trial
              if trial_id % n == 1:
                  return TrialMode.DISTILLATION
          return TrialMode.ENSEMBLE_SEARCH
  
      # Get the pool size for each mode.
      modes = []
      if has_ensemble_search(ensemble_spec):
          minimal_pool_size = 0
          if is_nonadaptive_ensemble_search(ensemble_spec):
              minimal_pool_size = (
                  ensemble_spec.nonadaptive_search.minimal_pool_size
              )
          elif is_adaptive_ensemble_search(
              ensemble_spec
          ) or is_residual_ensemble_search(ensemble_spec):
              minimal_pool_size = (
                  ensemble_spec.adaptive_search.minimal_pool_size
              )
          modes.append((TrialMode.ENSEMBLE_SEARCH, minimal_pool_size))
      if has_distillation(distillation_spec):
          modes.append(
              (
                  TrialMode.DISTILLATION,
                  distillation_spec.minimal_pool_size,
              )
          )
  
      # Check pool sizes to see what phase this trial is in.
      modes.sort(key=lambda x: (x[1], x[0]), reverse=True)
      for mode, n in modes:
          if trial_id > n:
              return mode
      return TrialMode.NO_PRIOR
  
imports: import copy
  import enum
  import os
  from model_search import hparam
  from model_search.architecture import architecture_utils
  from model_search.architecture import tower
  from model_search.generators import base_tower_generator
  from model_search.metadata import trial
  from model_search.proto import distillation_spec_pb2
  from model_search.proto import ensembling_spec_pb2
  from model_search.proto import phoenix_spec_pb2
  import tensorflow.compat.v2
  from google.protobuf import text_format
label_desc: Use image node_id 1 for calling a global function with example usage: get_trial_mode(ensemble_spec, distillation_spec, trial_id) and returns: TrialMode, TrialMode, mode, TrialMode