code: def _gpinv(probs, kappa, sigma):
      
      x = np.full_like(probs, np.nan)
      if sigma <= 0:
          return x
      ok = (probs > 0) & (probs < 1)
      if np.all(ok):
          if np.abs(kappa) < np.finfo(float).eps:
              x = -np.log1p(-probs)  # pylint: disable=invalid-unary-operand-type
          else:
              x = np.expm1(-kappa * np.log1p(-probs)) / kappa
          x *= sigma
      else:
          if np.abs(kappa) < np.finfo(float).eps:
              x[ok] = -np.log1p(-probs[ok])  # pylint: disable=unsupported-assignment-operation, E1130
          else:
              x[ok] = (  # pylint: disable=unsupported-assignment-operation
                  np.expm1(-kappa * np.log1p(-probs[ok])) / kappa
              )
          x *= sigma
          x[probs == 0] = 0
          if kappa >= 0:
              x[probs == 1] = np.inf  # pylint: disable=unsupported-assignment-operation
          else:
              x[probs == 1] = -sigma / kappa  # pylint: disable=unsupported-assignment-operation
  
      return x
docs: Inverse Generalized Pareto distribution function.