code: def test_base_example() -> None:
      # DOC_BASE_0
      import nevergrad as ng
  
      def square(x, y=12):
          return sum((x - 0.5) ** 2) + abs(y)
  
      # optimization on x as an array of shape (2,)
      optimizer = ng.optimizers.NGOpt(parametrization=2, budget=100)
      recommendation = optimizer.minimize(square)  # best value
      print(recommendation.value)
      # >>> [0.49971112 0.5002944 ]
      # DOC_BASE_1
      instrum = ng.p.Instrumentation(
          ng.p.Array(shape=(2,)).set_bounds(lower=-12, upper=12),
          y=ng.p.Scalar(),
      )
      optimizer = ng.optimizers.NGOpt(
          parametrization=instrum, budget=100
      )
      recommendation = optimizer.minimize(square)
      print(recommendation.value)
      # >>> ((array([0.52213095, 0.45030925]),), {'y': -0.0003603100877068604})
      # DOC_BASE_2
      from concurrent import futures
  
      optimizer = ng.optimizers.NGOpt(
          parametrization=instrum, budget=10, num_workers=2
      )
      # We use ThreadPoolExecutor for CircleCI but please
      # use the line just below, with ProcessPoolExecutor instead (unless your
      # code is I/O bound rather than CPU bound):
      with futures.ThreadPoolExecutor(
          max_workers=optimizer.num_workers
      ) as executor:
          # with futures.ProcessPoolExecutor(max_workers=optimizer.num_workers) as executor:
          recommendation = optimizer.minimize(
              square, executor=executor, batch_mode=False
          )
      # DOC_BASE_3
      import nevergrad as ng
  
      def square(x, y=12):
          return sum((x - 0.5) ** 2) + abs(y)
  
      instrum = ng.p.Instrumentation(
          ng.p.Array(shape=(2,)), y=ng.p.Scalar()
      )  # We are working on R^2 x R.
      optimizer = ng.optimizers.NGOpt(
          parametrization=instrum, budget=100, num_workers=1
      )
  
      for _ in range(optimizer.budget):
          x = optimizer.ask()
          loss = square(*x.args, **x.kwargs)
          optimizer.tell(x, loss)
  
      recommendation = optimizer.provide_recommendation()
      print(recommendation.value)
      # DOC_BASE_4
      import nevergrad as ng
  
      def onemax(x):
          return len(x) - x.count(1)
  
      # Discrete, ordered
      param = ng.p.TransitionChoice(range(7), repetitions=10)
      optimizer = ng.optimizers.DiscreteOnePlusOne(
          parametrization=param, budget=100, num_workers=1
      )
  
      recommendation = optimizer.provide_recommendation()
      for _ in range(optimizer.budget):
          x = optimizer.ask()
          # loss = onemax(*x.args, **x.kwargs)  # equivalent to x.value if not using Instrumentation
          loss = onemax(x.value)
          optimizer.tell(x, loss)
  
      recommendation = optimizer.provide_recommendation()
      print(recommendation.value)
  
file_path: nevergrad/nevergrad/optimization/test_doc.py
imports: import warnings
  import numpy
  import nevergrad
label_desc: Use image node_id 2 for calling a global function with example usage: test_base_example() and returns: unknown, unknown, unknown