docstr: Returns a classical discrete function for test, in the domain {0,1,...,arity-1}^d.
  The name can be onemax, leadingones, or jump.
  
  onemax(x) is the most classical case of discrete functions, adapted to minimization.
  It is originally designed for lists of bits. It just counts the number of 1,
  and returns len(x) - number of ones. However, the present function perturbates the location of the
  optimum, so that tests can not be easily biased by a wrong initialization. So the optimum,
  instead of being located at (1,1,...,1), is located at (0,1,2,...,arity-1,0,1,2,...).
  
  leadingones is the second most classical discrete function, adapted for minimization.
  Before perturbation of the location of the optimum as above,
  it returns len(x) - number of initial 1. I.e.
  leadingones([0 1 1 1]) = 4,
  leadingones([1 1 1 1]) = 0,
  leadingones([1 0 0 0]) = 3.
  The present Leadingones function uses a perturbation as documented above for OneMax: we count the number
  of initial correct values, a correct values being 0 for variable 1, 1 for variable 2, 2 for variable 3, and
  so on.
  
  There exists variants of jump functions: the principle of a jump function is that local descent does not succeed.
  Jumps are necessary. We are here in minimization, hence a formulation slightly different from most discrete optimization
  papers, which usually assume maximization. We use the same perturbation as detailed above for leadingones and onemax,
  i.e. the optimum is located at (0,1,2,...,arity-1,0,1,2,...).
code: def __init__(self, name: str, arity: int = 2) -> None:
      """Returns a classical discrete function for test, in the domain {0,1,...,arity-1}^d.
      The name can be onemax, leadingones, or jump.
  
      onemax(x) is the most classical case of discrete functions, adapted to minimization.
      It is originally designed for lists of bits. It just counts the number of 1,
      and returns len(x) - number of ones. However, the present function perturbates the location of the
      optimum, so that tests can not be easily biased by a wrong initialization. So the optimum,
      instead of being located at (1,1,...,1), is located at (0,1,2,...,arity-1,0,1,2,...).
  
      leadingones is the second most classical discrete function, adapted for minimization.
      Before perturbation of the location of the optimum as above,
      it returns len(x) - number of initial 1. I.e.
      leadingones([0 1 1 1]) = 4,
      leadingones([1 1 1 1]) = 0,
      leadingones([1 0 0 0]) = 3.
      The present Leadingones function uses a perturbation as documented above for OneMax: we count the number
      of initial correct values, a correct values being 0 for variable 1, 1 for variable 2, 2 for variable 3, and
      so on.
  
      There exists variants of jump functions: the principle of a jump function is that local descent does not succeed.
      Jumps are necessary. We are here in minimization, hence a formulation slightly different from most discrete optimization
      papers, which usually assume maximization. We use the same perturbation as detailed above for leadingones and onemax,
      i.e. the optimum is located at (0,1,2,...,arity-1,0,1,2,...).
      """
      self._arity = arity
      self._func = dict(
          onemax=self.onemax,
          leadingones=self.leadingones,
          jump=self.jump,
      )[name]
  
imports: from math import exp, sqrt, tanh
  import numpy
  import nevergrad.common.typing
  from nevergrad.common.decorators import Registry
label_desc: Use image node_id 1 to create a new DiscreteFunction object  with example: obj = DiscreteFunction(name, arity)