docstr: Primary entry point into the optimization
  :param fx:
  :param nb_iterations:
  :return:
docstr_tok: ["Primary","entry","point","into","the","optimization",":","param","fx",":",":","param","nb_iterations",":",":","return",":"]
code: def optimize(self, fx, nb_iterations=None):
      """
      Primary entry point into the optimization
      :param fx:
      :param nb_iterations:
      :return:
      """
      self.nb_iterations = nb_iterations
  
      # run first iteration
      result = fx(self)
  
      # log if requested
      if self.experiment is not None:
          result["hypo_iter_nb"] = self.current_iteration
          self.experiment.log(result)
  
      self.current_iteration += 1
  
      # generate the rest of the training seq
      # we couldn't do this before because we don't know
      # how many params the user needed
      self.__generate_trials()
  
      # run trials for the rest of the iterations
      # we either know the iterations or they're
      # calculated from the strategy used
      for i in range(1, len(self.trials)):
          result = fx(self)
          result["hypo_iter_nb"] = self.current_iteration
  
          # log if requested
          if self.experiment is not None:
              self.experiment.log(result)
  
          self.current_iteration += 1
  
file_path: test-tube/test_tube/hyperopt.py
imports: import itertools
  import json
  import random
label_desc: Use image node_id 7 for calling the HyperParamOptimizer obj's underlying member method code with example usage: obj.optimize(fx, nb_iterations) without return types