code: def solve_qp(P, Q, G, H):
      r"""
      Helper function to set up and solve the Quadratic Program (QP) in CVXPY.
      A QP problem has the following form:
      minimize      1/2 x' P x + Q' x
      subject to    G x <= H
  
      Here the QP solver is based on CVXPY and uses OSQP.
  
      Parameters
      ----------
      P : ndarray
          n x n matrix for the primal QP objective function.
      Q : ndarray
          n x 1 matrix for the primal QP objective function.
      G : ndarray
          m x n matrix for the inequality constraint.
      H : ndarray
          m x 1 matrix for the inequality constraint.
  
      Returns
      -------
      x : array
          Optimal solution to the QP problem.
      """
      x = cvxpy.Variable(Q.shape[0])
      P = cvxpy.Constant(P)
      objective = cvxpy.Minimize(
          0.5 * cvxpy.quad_form(x, P, True) + Q @ x
      )
      constraints = [G @ x <= H]
  
      # setting up the problem
      prob = cvxpy.Problem(objective, constraints)
      try:
          prob.solve()
          opt = np.array(x.value).reshape((Q.shape[0],))
      except cvxpy.error.SolverError:
          opt = np.empty((Q.shape[0],))
          opt[:] = np.NaN
  
      return opt
  
imports: from packaging.version import Version
  import numbers
  import warnings
  import numpy
  from dipy.core import geometry
  from dipy.core.gradients import GradientTable, gradient_table, unique_bvals_tolerance, get_bval_indices
  from dipy.data import default_sphere
  from dipy.reconst import shm
  from dipy.reconst.csdeconv import response_from_mask_ssst
  from dipy.reconst.dti import TensorModel, fractional_anisotropy, mean_diffusivity
  from dipy.reconst.multi_voxel import multi_voxel_fit
  from dipy.reconst.utils import _roi_in_volume, _mask_from_roi
  from dipy.sims.voxel import single_tensor
  from dipy.utils.optpkg import optional_package
label_desc: Use image node_id 4 for calling a global function with example usage: solve_qp(P, Q, G, H) and returns: opt