code: def threshold_discretization(
      x: tp.ArrayLike, arity: int = 2
  ) -> tp.List[int]:
      """Discretize by casting values from 0 to arity -1, assuming that x values
      follow a normal distribution.
  
      Parameters
      ----------
      x: list/array
         values to discretize
      arity: int
         the number of possible integer values (arity n will lead to values from 0 to n - 1)
  
      Note
      ----
      - nans are processed as negative infs (yields 0)
      """
      x = np.array(x, copy=True)
      if np.any(np.isnan(x)):
          warnings.warn("Encountered NaN values for discretization")
          x[np.isnan(x)] = -np.inf
      if arity == 2:  # special case, to have 0 yield 0
          return (np.array(x) > 0).astype(int).tolist()  # type: ignore
      else:
          return (
              np.clip(arity * scipy.stats.norm.cdf(x), 0, arity - 1)
              .astype(int)
              .tolist()
          )
  
file_path: nevergrad/nevergrad/parametrization/discretization.py
imports: import warnings
  import numpy
  import scipy.stats
  import nevergrad.common.typing
label_desc: Use image node_id 1 for calling a global function with example usage: threshold_discretization(x, arity) and returns: unknown, np