class_docstr: Toy PBT problem for benchmarking adaptive learning rate.
  
  The goal is to optimize this trainable's accuracy. The accuracy increases
  fastest at the optimal lr, which is a function of the current accuracy.
  
  The optimal lr schedule for this problem is the triangle wave as follows.
  Note that many lr schedules for real models also follow this shape:
  
   best lr
    ^
    |    /      |   /        |  /          | /            ------------> accuracy
  
  In this problem, using PBT with a population of 2-4 is sufficient to
  roughly approximate this lr schedule. Higher population sizes will yield
  faster convergence. Training will not converge without PBT.
class_docstr_tok: ["Toy","PBT","problem","for","benchmarking","adaptive","learning","rate",".","The","goal","is","to","optimize","this","trainable","'s","accuracy",".","The","accuracy","increases","fastest","at","the","optimal","lr",",","which","is","a","function","of","the","current","accuracy",".","The","optimal","lr","schedule","for","this","problem","is","the","triangle","wave","as","follows",".","Note","that","many","lr","schedules","for","real","models","also","follow","this","shape",":","best","lr","^","|","\/","|","\/","|","\/","|","\/","--","--","--","--","--","--",">","accuracy","In","this","problem",",","using","PBT","with","a","population","of","2-4","is","sufficient","to","roughly","approximate","this","lr","schedule",".","Higher","population","sizes","will","yield","faster","convergence",".","Training","will","not","converge","without","PBT","."]
code: def step(self):
      midpoint = 100  # lr starts decreasing after acc > midpoint
      q_tolerance = (
          3  # penalize exceeding lr by more than this multiple
      )
      noise_level = 2  # add gaussian noise to the acc increase
      # triangle wave:
      #  - start at 0.001 @ t=0,
      #  - peak at 0.01 @ t=midpoint,
      #  - end at 0.001 @ t=midpoint * 2,
      if self.accuracy < midpoint:
          optimal_lr = 0.01 * self.accuracy / midpoint
      else:
          optimal_lr = (
              0.01 - 0.01 * (self.accuracy - midpoint) / midpoint
          )
      optimal_lr = min(0.01, max(0.001, optimal_lr))
  
      # compute accuracy increase
      q_err = max(self.lr, optimal_lr) / min(self.lr, optimal_lr)
      if q_err < q_tolerance:
          self.accuracy += (1.0 / q_err) * random.random()
      elif self.lr > optimal_lr:
          self.accuracy -= (q_err - q_tolerance) * random.random()
      self.accuracy += noise_level * np.random.normal()
      self.accuracy = max(0, self.accuracy)
  
      return {
          "mean_accuracy": self.accuracy,
          "cur_lr": self.lr,
          "optimal_lr": optimal_lr,  # for debugging
          "q_err": q_err,  # for debugging
          "done": self.accuracy > midpoint * 2,
      }
  
file_path: ray/python/ray/tune/examples/pbt_example.py
imports: import numpy
  import argparse
  import random
  import ray
  from ray import train, tune
  from ray.tune.schedulers import PopulationBasedTraining
label_desc: Use image node_id 2 for calling the PBTBenchmarkExample obj's underlying member method code with example usage: obj.step() and returns: dict