code: def _check_result(x, fun, status, slack, con, lb, ub, tol, message):
      """
      Check the validity of the provided solution.
  
      A valid (optimal) solution satisfies all bounds, all slack variables are
      negative and all equality constraint residuals are strictly non-zero.
      Further, the lower-bounds, upper-bounds, slack and residuals contain
      no nan values.
  
      Parameters
      ----------
      x : 1D array
          Solution vector to original linear programming problem
      fun: float
          optimal objective value for original problem
      status : int
          An integer representing the exit status of the optimization::
  
               0 : Optimization terminated successfully
               1 : Iteration limit reached
               2 : Problem appears to be infeasible
               3 : Problem appears to be unbounded
               4 : Serious numerical difficulties encountered
  
      slack : 1D array
          The (non-negative) slack in the upper bound constraints, that is,
          ``b_ub - A_ub @ x``
      con : 1D array
          The (nominally zero) residuals of the equality constraints, that is,
          ``b - A_eq @ x``
      lb : 1D array
          The lower bound constraints on the original variables
      ub: 1D array
          The upper bound constraints on the original variables
      message : str
          A string descriptor of the exit status of the optimization.
      tol : float
          Termination tolerance; see [1]_ Section 4.5.
  
      Returns
      -------
      status : int
          An integer representing the exit status of the optimization::
  
               0 : Optimization terminated successfully
               1 : Iteration limit reached
               2 : Problem appears to be infeasible
               3 : Problem appears to be unbounded
               4 : Serious numerical difficulties encountered
  
      message : str
          A string descriptor of the exit status of the optimization.
      """
      # Somewhat arbitrary, but status 5 is very unusual
      tol = np.sqrt(tol) * 10
  
      contains_nans = (
          np.isnan(x).any()
          or np.isnan(fun)
          or np.isnan(slack).any()
          or np.isnan(con).any()
      )
  
      if contains_nans:
          is_feasible = False
      else:
          invalid_bounds = (x < lb - tol).any() or (x > ub + tol).any()
          invalid_slack = status != 3 and (slack < -tol).any()
          invalid_con = status != 3 and (np.abs(con) > tol).any()
          is_feasible = not (
              invalid_bounds or invalid_slack or invalid_con
          )
  
      if status == 0 and not is_feasible:
          status = 4
          message = (
              "The solution does not satisfy the constraints, yet "
              "no errors were raised and there is no certificate of "
              "infeasibility or unboundedness. This is known to occur "
              "if the `presolve` option is False and the problem is "
              "infeasible. If you encounter this under different "
              "circumstances, please submit a bug report. Otherwise, "
              "please enable presolve."
          )
      elif status == 0 and contains_nans:
          status = 4
          message = (
              "Numerical difficulties were encountered but no errors "
              "were raised. This is known to occur if the 'presolve' "
              "option is False, 'sparse' is True, and A_eq includes "
              "redundant rows. If you encounter this under different "
              "circumstances, please submit a bug report. Otherwise, "
              "remove linearly dependent equations from your equality "
              "constraints or enable presolve."
          )
      elif status == 2 and is_feasible:
          # Occurs if the simplex method exits after phase one with a very
          # nearly basic feasible solution. Postsolving can make the solution
          # basic, however, this solution is NOT optimal
          raise ValueError(message)
  
      return status, message
  
file_path: catboost/contrib/python/scipy/py2/scipy/optimize/_linprog_util.py
imports: import numpy
  import scipy.sparse
  from warnings import warn
  from .optimize import OptimizeWarning
  from scipy.optimize._remove_redundancy import _remove_redundancy, _remove_redundancy_sparse, _remove_redundancy_dense
label_desc: Use image node_id 8 for calling a global function with example usage: _check_result(x, fun, status, slack, con, lb, ub, tol, message) and returns: status,  message