code: def tr_interior_point(
      fun,
      grad,
      lagr_hess,
      n_vars,
      n_ineq,
      n_eq,
      constr,
      jac,
      x0,
      fun0,
      grad0,
      constr_ineq0,
      jac_ineq0,
      constr_eq0,
      jac_eq0,
      stop_criteria,
      enforce_feasibility,
      xtol,
      state,
      initial_barrier_parameter,
      initial_tolerance,
      initial_penalty,
      initial_trust_radius,
      factorization_method,
  ):
      """Trust-region interior points method.
  
      Solve problem:
          minimize fun(x)
          subject to: constr_ineq(x) <= 0
                      constr_eq(x) = 0
      using trust-region interior point method described in [1]_.
      """
      # BOUNDARY_PARAMETER controls the decrease on the slack
      # variables. Represents ``tau`` from [1]_ p.885, formula (3.18).
      BOUNDARY_PARAMETER = 0.995
      # BARRIER_DECAY_RATIO controls the decay of the barrier parameter
      # and of the subproblem toloerance. Represents ``theta`` from [1]_ p.879.
      BARRIER_DECAY_RATIO = 0.2
      # TRUST_ENLARGEMENT controls the enlargement on trust radius
      # after each iteration
      TRUST_ENLARGEMENT = 5
  
      # Default enforce_feasibility
      if enforce_feasibility is None:
          enforce_feasibility = np.zeros(n_ineq, bool)
      # Initial Values
      barrier_parameter = initial_barrier_parameter
      tolerance = initial_tolerance
      trust_radius = initial_trust_radius
      # Define initial value for the slack variables
      s0 = np.maximum(-1.5 * constr_ineq0, np.ones(n_ineq))
      # Define barrier subproblem
      subprob = BarrierSubproblem(
          x0,
          s0,
          fun,
          grad,
          lagr_hess,
          n_vars,
          n_ineq,
          n_eq,
          constr,
          jac,
          barrier_parameter,
          tolerance,
          enforce_feasibility,
          stop_criteria,
          xtol,
          fun0,
          grad0,
          constr_ineq0,
          jac_ineq0,
          constr_eq0,
          jac_eq0,
      )
      # Define initial parameter for the first iteration.
      z = np.hstack((x0, s0))
      fun0_subprob, constr0_subprob = subprob.fun0, subprob.constr0
      grad0_subprob, jac0_subprob = subprob.grad0, subprob.jac0
      # Define trust region bounds
      trust_lb = np.hstack(
          (
              np.full(subprob.n_vars, -np.inf),
              np.full(subprob.n_ineq, -BOUNDARY_PARAMETER),
          )
      )
      trust_ub = np.full(subprob.n_vars + subprob.n_ineq, np.inf)
  
      # Solves a sequence of barrier problems
      while True:
          # Solve SQP subproblem
          z, state = equality_constrained_sqp(
              subprob.function_and_constraints,
              subprob.gradient_and_jacobian,
              subprob.lagrangian_hessian,
              z,
              fun0_subprob,
              grad0_subprob,
              constr0_subprob,
              jac0_subprob,
              subprob.stop_criteria,
              state,
              initial_penalty,
              trust_radius,
              factorization_method,
              trust_lb,
              trust_ub,
              subprob.scaling,
          )
          if subprob.terminate:
              break
          # Update parameters
          trust_radius = max(
              initial_trust_radius, TRUST_ENLARGEMENT * state.tr_radius
          )
          # TODO: Use more advanced strategies from [2]_
          # to update this parameters.
          barrier_parameter *= BARRIER_DECAY_RATIO
          tolerance *= BARRIER_DECAY_RATIO
          # Update Barrier Problem
          subprob.update(barrier_parameter, tolerance)
          # Compute initial values for next iteration
          (
              fun0_subprob,
              constr0_subprob,
          ) = subprob.function_and_constraints(z)
          grad0_subprob, jac0_subprob = subprob.gradient_and_jacobian(z)
  
      # Get x and s
      x = subprob.get_variables(z)
      return x, state
  
imports: import scipy.sparse
  import numpy
  from .equality_constrained_sqp import equality_constrained_sqp
  from scipy.sparse.linalg import LinearOperator
label_desc: Use image node_id 1 for calling a global function with example usage: tr_interior_point(fun, grad, lagr_hess, n_vars, n_ineq, n_eq, constr, jac, x0, fun0, grad0, constr_ineq0, jac_ineq0, constr_eq0, jac_eq0, stop_criteria, enforce_feasibility, xtol, state, initial_barrier_parameter, initial_tolerance, initial_penalty, initial_trust_radius, factorization_method) and returns: x,  state