code: def grad_optimize_ei_over_hypers(
      self, cand, comp, pend, vals, labels, compute_grad=True
  ):
      summed_ei = 0
      summed_grad_ei = np.zeros(cand.shape).flatten()
  
      for mcmc_iter in range(self.mcmc_iters):
          hyper = self.hyper_samples[mcmc_iter]
          constraint_hyper = self.constraint_hyper_samples[mcmc_iter]
          self.mean = hyper[0]
          self.noise = hyper[1]
          self.amp2 = hyper[2]
          self.ls = hyper[3]
  
          self.constraint_mean = constraint_hyper[0]
          self.constraint_gain = constraint_hyper[1]
          self.constraint_amp2 = constraint_hyper[2]
          self.constraint_ls = constraint_hyper[3]
          if compute_grad:
              (ei, g_ei) = self.grad_optimize_ei(
                  cand, comp, pend, vals, labels, compute_grad
              )
              summed_grad_ei = summed_grad_ei + g_ei
          else:
              ei = self.grad_optimize_ei(
                  cand, comp, pend, vals, labels, compute_grad
              )
  
          summed_ei += ei
  
      if compute_grad:
          return (summed_ei, summed_grad_ei)
      else:
          return summed_ei
  
imports: import os
  from ..None import gp
  import sys
  from ..None import util
  import tempfile
  import numpy
  import math
  import numpy.random
  import scipy.linalg
  import scipy.stats
  import scipy.optimize
  import pickle
  import matplotlib.pyplot
  import multiprocessing
  import copy
  from ..helpers import *
  from ..Locker import *
  import logging
label_desc: Use image node_id 8 for calling the GPConstrainedEIChooser obj's underlying member method code with example usage: obj.grad_optimize_ei_over_hypers(cand, comp, pend, vals, labels, compute_grad) and returns: summed_ei,  summed_grad_ei, summed_ei