class_docstr: Recast Optimizer which cannot deal with parallelization
  
  There can only be one worker. Each ask must be followed by
  a tell.
  
  A simple usage is that you have a library which can minimize
  a function which returns a scalar.
  Just make an optimizer inheriting from this class, and inplement
  get_optimization_function to return a callable which runs the
  optimization, taking the objective as its only parameter. The
  callable must not have any references to the optimizer itself.
  (This avoids a reference cycle between the background thread and
  the optimizer, aiding cleanup.) It can have a weakref though.
  
  If you want your optimizer instance to be picklable, we have to
  store every candidate during optimization, which may use a lot
  of memory. This lets us replay the optimization when
  unpickling. We only do this if you ask for it. To enable:
      - The optimization must be reproducible, asking for the same
        candidates every time. If you need a seed from nevergrad's
        generator, you can't necessarily generate this again after
        unpickling. One solution is to store it in self, if it is
        not there yet, in the body of get_optimization_function.
  
        As in general in nevergrad, do not set the seed from the
        RNG in your own __init__ because it will cause surprises
        to anyone re-seeding your parametrization after init.
      - The user must call enable_pickling() after initializing
        the optimizer instance.
class_docstr_tok: ["Recast","Optimizer","which","can","not","deal","with","parallelization","There","can","only","be","one","worker",".","Each","ask","must","be","followed","by","a","tell",".","A","simple","usage","is","that","you","have","a","library","which","can","minimize","a","function","which","returns","a","scalar",".","Just","make","an","optimizer","inheriting","from","this","class",",","and","inplement","get_optimization_function","to","return","a","callable","which","runs","the","optimization",",","taking","the","objective","as","its","only","parameter",".","The","callable","must","not","have","any","references","to","the","optimizer","itself",".","(","This","avoids","a","reference","cycle","between","the","background","thread","and","the","optimizer",",","aiding","cleanup",".",")","It","can","have","a","weakref","though",".","If","you","want","your","optimizer","instance","to","be","picklable",",","we","have","to","store","every","candidate","during","optimization",",","which","may","use","a","lot","of","memory",".","This","lets","us","replay","the","optimization","when","unpickling",".","We","only","do","this","if","you","ask","for","it",".","To","enable",":","-","The","optimization","must","be","reproducible",",","asking","for","the","same","candidates","every","time",".","If","you","need","a","seed","from","nevergrad's","generator",",","you","ca","n't","necessarily","generate","this","again","after","unpickling",".","One","solution","is","to","store","it","in","self",",","if","it","is","not","there","yet",",","in","the","body","of","get_optimization_function",".","As","in","general","in","nevergrad",",","do","not","set","the","seed","from","the","RNG","in","your","own","__init__","because","it","will","cause","surprises","to","anyone","re-seeding","your","parametrization","after","init",".","-","The","user","must","call","enable_pickling","(",")","after","initializing","the","optimizer","instance","."]
code: def __init__(
      self,
      parametrization: IntOrParameter,
      budget: tp.Optional[int],
      num_workers: int = 1,
  ) -> None:
      super().__init__(
          parametrization=parametrization,
          budget=budget,
          num_workers=num_workers,
      )
      self._enable_pickling = False
      self.replay_archive_tell: tp.List[p.Parameter] = []
  
imports: import warnings
  import threading
  import queue
  import numpy
  import nevergrad.common.typing
  from nevergrad.common.errors import NevergradError
  from nevergrad.parametrization import parameter
  from .None import base
  from .base import IntOrParameter
label_desc: Use image node_id 1 to create a new SequentialRecastOptimizer object from inherited base classes: RecastOptimizer with example: obj = SequentialRecastOptimizer(parametrization, budget, num_workers)