code: def _replace_inf(x):
      # Replace `np.inf` with CONST_INF
      infs = np.isinf(x)
      with np.errstate(invalid="ignore"):
          x[infs] = np.sign(x[infs]) * CONST_INF
      return x
  
file_path: scipy/scipy/optimize/_linprog_highs.py
imports: import inspect
  import numpy
  from ._optimize import OptimizeWarning, OptimizeResult
  from warnings import warn
  from ._highs._highs_wrapper import _highs_wrapper
  from ._highs._highs_constants import CONST_INF, MESSAGE_LEVEL_NONE, HIGHS_OBJECTIVE_SENSE_MINIMIZE, MODEL_STATUS_NOTSET, MODEL_STATUS_LOAD_ERROR, MODEL_STATUS_MODEL_ERROR, MODEL_STATUS_PRESOLVE_ERROR, MODEL_STATUS_SOLVE_ERROR, MODEL_STATUS_POSTSOLVE_ERROR, MODEL_STATUS_MODEL_EMPTY, MODEL_STATUS_OPTIMAL, MODEL_STATUS_INFEASIBLE, MODEL_STATUS_UNBOUNDED_OR_INFEASIBLE, MODEL_STATUS_UNBOUNDED, MODEL_STATUS_REACHED_DUAL_OBJECTIVE_VALUE_UPPER_BOUND, MODEL_STATUS_REACHED_OBJECTIVE_TARGET, MODEL_STATUS_REACHED_TIME_LIMIT, MODEL_STATUS_REACHED_ITERATION_LIMIT, HIGHS_SIMPLEX_STRATEGY_DUAL, HIGHS_SIMPLEX_CRASH_STRATEGY_OFF, HIGHS_SIMPLEX_EDGE_WEIGHT_STRATEGY_CHOOSE, HIGHS_SIMPLEX_EDGE_WEIGHT_STRATEGY_DANTZIG, HIGHS_SIMPLEX_EDGE_WEIGHT_STRATEGY_DEVEX, HIGHS_SIMPLEX_EDGE_WEIGHT_STRATEGY_STEEPEST_EDGE
  from scipy.sparse import csc_matrix, vstack, issparse
label_desc: Use image node_id 2 for calling a global function with example usage: _replace_inf(x) and returns: x