class_docstr: Truncate Exploit
  
  If the given trial is under a ``truncation_quantile`` compared to all other trials that
  has reached the same fidelity level, then a new candidate trial is selected for forking.
  The new candidate is selected from a pool of best ``candidate_pool_ratio``\% of the available
  trials at the same fidelity level.
  
  If there are less than ``min_forking_population`` trials that have reached the fidelity level
  as the passed trial, then `None` is return to signal that we should reconsider this trial later
  on when more trials are completed at this fidelity level.
  
  Parameters
  ----------
  min_forking_population: int, optional
      Minimum number of trials that should be completed up to the fidelity level of the current
      trial passed. TruncateExploit will return ``None`` when this requirement is not met.
      Default: 5
  truncation_quantile: float, optional
      If the passed trial's objective is above quantile ``truncation_quantile``, then another
      candidate is considered for forking. Default: 0.8
  candidate_pool_ratio: float, optional
      When choosing another candidate for forking, it will be randomly selected from the
      best ``candidate_pool_ratio``\% of the available trials. Default: 0.2
class_docstr_tok: ["Truncate","Exploit","If","the","given","trial","is","under","a","``","truncation_quantile","``","compared","to","all","other","trials","that","has","reached","the","same","fidelity","level",",","then","a","new","candidate","trial","is","selected","for","forking",".","The","new","candidate","is","selected","from","a","pool","of","best","``","candidate_pool_ratio","``","\\","%","of","the","available","trials","at","the","same","fidelity","level",".","If","there","are","less","than","``","min_forking_population","``","trials","that","have","reached","the","fidelity","level","as","the","passed","trial",",","then","`","None","`","is","return","to","signal","that","we","should","reconsider","this","trial","later","on","when","more","trials","are","completed","at","this","fidelity","level",".","Parameters","--","--","--","--","--","min_forking_population",":","int",",","optional","Minimum","number","of","trials","that","should","be","completed","up","to","the","fidelity","level","of","the","current","trial","passed",".","TruncateExploit","will","return","``","None","``","when","this","requirement","is","not","met",".","Default",":","5","truncation_quantile",":","float",",","optional","If","the","passed","trial","'s","objective","is","above","quantile","``","truncation_quantile","``",",","then","another","candidate","is","considered","for","forking",".","Default",":","0.8","candidate_pool_ratio",":","float",",","optional","When","choosing","another","candidate","for","forking",",","it","will","be","randomly","selected","from","the","best","``","candidate_pool_ratio","``","\\","%","of","the","available","trials",".","Default",":","0.2"]
code: def _truncate(
      self,
      rng,
      trial,
      trials,
  ):
      completed_trials = [
          trial for trial in trials if trial.status == "completed"
      ]
  
      if len(completed_trials) < self.min_forking_population:
          logger.debug(
              "Not enough trials completed to exploit: %s",
              len(completed_trials),
          )
          return None
  
      if trial not in completed_trials:
          raise ValueError(
              f"Trial {trial.id} not included in list of completed trials."
          )
  
      sorted_trials = sorted(
          completed_trials, key=lambda trial: trial.objective.value
      )
  
      worse_trials = sorted_trials[
          int(self.truncation_quantile * len(sorted_trials)) :
      ]
  
      if trial not in worse_trials:
          logger.debug(
              "Trial %s is good enough, no need to exploit.", trial
          )
          return trial
  
      candidate_threshold_index = int(
          self.candidate_pool_ratio * len(sorted_trials)
      )
  
      if candidate_threshold_index == 0:
          logger.warning(
              "Not enough completed trials to have a candidate pool. "
              "You should consider increasing min_forking_population or candidate_pool_ratio"
          )
          return None
  
      index = rng.choice(numpy.arange(0, candidate_threshold_index))
      return sorted_trials[index]
  
imports: import logging
  import numpy
  from orion.core.utils import GenericFactory
label_desc: Use image node_id 3 for calling the TruncateExploit obj's underlying member method code with example usage: obj._truncate(rng, trial, trials) and returns: sorted_trials, None, trial, None