class_docstr: Generates candidates towers for Phoenix via search algorithms.
class_docstr_tok: ["Generates","candidates","towers","for","Phoenix","via","search","algorithms","."]
code: def first_time_chief_generate(
      self,
      input_layer_fn,
      trial_mode,
      logits_dimension,
      hparams,
      run_config,
      is_training,
      trials,
  ):
      dropout_rate = getattr(hparams, "dropout_rate", None)
      my_id = architecture_utils.DirectoryHandler.get_trial_id(
          run_config.model_dir, self._phoenix_spec
      )
      create_new_architecture_fn = functools.partial(
          self._create_new_architecture,
          run_config=run_config,
          my_id=my_id,
          hparams=hparams,
          is_training=is_training,
          logits_dimension=logits_dimension,
          dropout_rate=dropout_rate,
          trials=trials,
      )
  
      suggest_and_create_architecture_fn = functools.partial(
          _suggest_and_create_architecture,
          create_new_architecture_fn=create_new_architecture_fn,
          hparams=hparams,
          my_id=my_id,
          run_config=run_config,
          search_algorithm=self._search_algorithm,
          phoenix_spec=self._phoenix_spec,
          input_layer_fn=input_layer_fn,
          is_training=is_training,
          logits_dimension=logits_dimension,
          dropout_rate=dropout_rate,
          aux=self._allow_auxiliary_head,
      )
  
      # First, try out user suggestions.
      if my_id <= len(self._phoenix_spec.user_suggestions):
          return create_new_architecture_fn(
              architecture=self._get_user_suggestion(my_id),
              prev_trial=-1,
          )
  
      if trial_mode == trial_utils.TrialMode.ENSEMBLE_SEARCH:
          # Non-adaptive ensemble search.
          if trial_utils.is_nonadaptive_ensemble_search(
              self._ensemble_spec
          ):
              # Done searching if we've hit critical mass.
              architecture_utils.set_number_of_towers(
                  self.generator_name(), 0
              )
              return [], []
  
          # Adaptive and residual ensemble search.
          elif trial_utils.is_adaptive_ensemble_search(
              self._ensemble_spec
          ) or trial_utils.is_residual_ensemble_search(
              self._ensemble_spec
          ):
              every = (
                  self._ensemble_spec.adaptive_search.increase_width_every
              )
              relevant_trials = trials
              if every:
                  relevant_trials = [
                      trial
                      for trial in trials
                      if trial.id >= my_id // every * every
                  ]
              return suggest_and_create_architecture_fn(
                  relevant_trials=relevant_trials
              )
  
          # Intermixed ensemble search.
          elif trial_utils.is_intermixed_ensemble_search(
              self._ensemble_spec
          ):
              every = (
                  self._ensemble_spec.intermixed_search.try_ensembling_every
              )
  
              # Do not search if this is a non-exploration trial.
              if my_id % every == 0:
                  architecture_utils.set_number_of_towers(
                      self.generator_name(), 0
                  )
                  return [], []
  
              # Search if this is an exploration trial.
              relevant_trials = [
                  trial for trial in trials if trial.id % every != 0
              ]
              return suggest_and_create_architecture_fn(
                  relevant_trials=relevant_trials
              )
  
          else:
              raise ValueError(
                  "Unknown ensemble search type '{}'".format(
                      self._ensemble_spec.ensemble_search_type
                  )
              )
  
      if (
          trial_mode == trial_utils.TrialMode.DISTILLATION
          and trial_utils.is_intermixed_ensemble_search(
              self._ensemble_spec
          )
      ):
          relevant_trials = trial_utils.get_intermixed_trials(
              trials,
              self._ensemble_spec.intermixed_search.try_ensembling_every,
              len(self._phoenix_spec.user_suggestions),
          )
          best_trial = self._metadata.get_best_k(
              trials=relevant_trials, k=1
          )
          if best_trial is not None:
              model_dir = architecture_utils.DirectoryHandler.trial_dir(
                  best_trial
              )
              assert (
                  architecture_utils.get_number_of_towers(
                      model_dir, self.generator_name()
                  )
                  == 1
              )
              tower_name = self.generator_name() + "_0"
              tower_ = tower.Tower.load(
                  phoenix_spec=self._phoenix_spec,
                  original_tower_name=tower_name,
                  new_tower_name=tower_name,
                  model_directory=model_dir,
                  new_model_directory=run_config.model_dir,
                  is_training=is_training,
                  logits_dimension=logits_dimension,
                  force_freeze=False,
                  allow_auxiliary_head=self._allow_auxiliary_head,
              )
              architecture_utils.set_number_of_towers(
                  self.generator_name(), 1
              )
              return [tower_]
  
      # If no ensembling search method is specified, or this is a distillation
      # trial without intermixed ensemble_search, get a new tower based on the
      # architecture search algorithm.
      # This will serve as the student model if distillation occurs on this trial.
      return suggest_and_create_architecture_fn(relevant_trials=trials)
  
imports: import functools
  from absl import logging
  from model_search import block_builder
  from model_search import search
  from model_search.architecture import architecture_utils
  from model_search.architecture import tower
  from model_search.generators import base_tower_generator
  from model_search.generators import trial_utils
  from model_search.proto import phoenix_spec_pb2
  from model_search.proto import transfer_learning_spec_pb2
  import numpy
  import tensorflow.compat.v2
label_desc: Use image node_id 6 for calling the SearchCandidateGenerator obj's underlying member method code with example usage: obj.first_time_chief_generate(input_layer_fn, trial_mode, logits_dimension, hparams, run_config, is_training, trials) and returns: suggest_and_create_architecture_fn, create_new_architecture_fn, list,  list, list, suggest_and_create_architecture_fn, suggest_and_create_architecture_fn, list,  list