class_docstr: Class providing the core functionality of a parameter, aka
  value, internal/model parameters, mutation, recombination
  and additional features such as shared random state,
  constraint check, hashes, generation and naming.
  The value field should sent to the function to optimize.
  
  Example
  -------
  >>> ng.p.Array(shape=(2,)).value
  array([0., 0.])
docstr: Registers a new constraint on the parameter values.
  
  Parameters
  ----------
  func: Callable
      function which, given the value of the instance, returns whether it satisfies the constraints (if output = bool),
      or a float which is >= 0 if the constraint is satisfied.
  
  Note
  ----
  - this is only for checking after mutation/recombination/etc if the value still satisfy the constraints.
    The constraint is not used in those processes.
  - constraints should be fast to compute.
  - this function has an additional "as_layer" parameter which is experimental for now, and can have unexpected
    behavior
docstr_tok: ["Registers","a","new","constraint","on","the","parameter","values",".","Parameters","--","--","--","--","--","func",":","Callable","function","which",",","given","the","value","of","the","instance",",","returns","whether","it","satisfies","the","constraints","(","if","output","=","bool",")",",","or","a","float","which","is",">","=","0","if","the","constraint","is","satisfied",".","Note","--","--","-","this","is","only","for","checking","after","mutation\/recombination\/etc","if","the","value","still","satisfy","the","constraints",".","The","constraint","is","not","used","in","those","processes",".","-","constraints","should","be","fast","to","compute",".","-","this","function","has","an","additional","``","as_layer","''","parameter","which","is","experimental","for","now",",","and","can","have","unexpected","behavior"]
code: def register_cheap_constraint(
      self,
      func: tp.Union[
          tp.Callable[[tp.Any], bool], tp.Callable[[tp.Any], float]
      ],
      as_layer: bool = False,
  ) -> None:
      """Registers a new constraint on the parameter values.
  
      Parameters
      ----------
      func: Callable
          function which, given the value of the instance, returns whether it satisfies the constraints (if output = bool),
          or a float which is >= 0 if the constraint is satisfied.
  
      Note
      ----
      - this is only for checking after mutation/recombination/etc if the value still satisfy the constraints.
        The constraint is not used in those processes.
      - constraints should be fast to compute.
      - this function has an additional "as_layer" parameter which is experimental for now, and can have unexpected
        behavior
      """
      if (
          getattr(func, "__name__", "not lambda") == "<lambda>"
      ):  # LambdaType does not work :(
          warnings.warn(
              "Lambda as constraint is not advised because it may not be picklable."
          )
      if not as_layer:
          self._constraint_checkers.append(func)
      else:
          from nevergrad.ops.constraints import Constraint
          import nevergrad as ng
  
          compat_func = (
              func
              if not isinstance(self, ng.p.Instrumentation)
              else utils._ConstraintCompatibilityFunction(func)
          )
          self.add_layer(Constraint(compat_func))
  
imports: import uuid
  import warnings
  import numpy
  import nevergrad.common.typing
  from nevergrad.common import errors
  from .None import utils
  from ._layering import ValueProperty
  from ._layering import Layered
  from ._layering import Level
label_desc: Use image node_id 20 for calling the Parameter obj's underlying member method code with example usage: obj.register_cheap_constraint(func, as_layer) without return types