code: def test_constraint(num: int) -> None:
      parameter = ng.p.Instrumentation(
          *(ng.p.Scalar(np.random.randn()) for _ in range(num))
      )
      constrained = constraints.Constraint(function)(parameter)
      # check basic layer functionalities
      layer: constraints.Constraint = constrained._layers[-1]  # type: ignore
      assert (
          layer.function(*([1] * num)) == 1 if num == 1 else [1] * num
      )
      assert (
          layer.function(*([-1] * num)) == 0 if num == 1 else [0] * num
      )
      assert (
          np.mean([x < 0.1 for x in constrained.args]) > 0.5
      ), constrained.args
  
imports: import typing
  import pytest
  import numpy
  import nevergrad
  from .None import constraints
label_desc: Use image node_id 2 for calling a global function with example usage: test_constraint(num) without return types