code: def do_trim_params(
      params,
      k_params,
      alpha,
      score,
      passed,
      trim_mode,
      size_trim_tol,
      auto_trim_tol,
  ):
      """
      Trims (set to zero) params that are zero at the theoretical minimum.
      Uses heuristics to account for the solver not actually finding the minimum.
  
      In all cases, if alpha[i] == 0, then do not trim the ith param.
      In all cases, do nothing with the added variables.
  
      Parameters
      ----------
      params : ndarray
          model parameters.  Not including added variables.
      k_params : Int
          Number of parameters
      alpha : ndarray
          regularization coefficients
      score : Function.
          score(params) should return a 1-d vector of derivatives of the
          unpenalized objective function.
      passed : bool
          True if the QC check passed
      trim_mode : 'auto, 'size', or 'off'
          If not 'off', trim (set to zero) parameters that would have been zero
              if the solver reached the theoretical minimum.
          If 'auto', trim params using the Theory above.
          If 'size', trim params if they have very small absolute value
      size_trim_tol : float or 'auto' (default = 'auto')
          For use when trim_mode === 'size'
      auto_trim_tol : float
          For sue when trim_mode == 'auto'.  Use
      qc_tol : float
          Print warning and do not allow auto trim when (ii) in "Theory" (above)
          is violated by this much.
  
      Returns
      -------
      params : ndarray
          Trimmed model parameters
      trimmed : ndarray of booleans
          trimmed[i] == True if the ith parameter was trimmed.
      """
      ## Trim the small params
      trimmed = [False] * k_params
  
      if trim_mode == "off":
          trimmed = np.array([False] * k_params)
      elif trim_mode == "auto" and not passed:
          import warnings
  
          msg = (
              "Could not trim params automatically due to failed QC check. "
              "Trimming using trim_mode == 'size' will still work."
          )
          warnings.warn(msg, ConvergenceWarning)
          trimmed = np.array([False] * k_params)
      elif trim_mode == "auto" and passed:
          fprime = score(params)
          for i in range(k_params):
              if alpha[i] != 0:
                  if (alpha[i] - abs(fprime[i])) / alpha[
                      i
                  ] > auto_trim_tol:
                      params[i] = 0.0
                      trimmed[i] = True
      elif trim_mode == "size":
          for i in range(k_params):
              if alpha[i] != 0:
                  if abs(params[i]) < size_trim_tol:
                      params[i] = 0.0
                      trimmed[i] = True
      else:
          raise ValueError(
              "trim_mode == %s, which is not recognized" % (trim_mode)
          )
  
      return params, np.asarray(trimmed)
  
imports: import numpy
  from statsmodels.tools.sm_exceptions import ConvergenceWarning
label_desc: Use image node_id 3 for calling a global function with example usage: do_trim_params(params, k_params, alpha, score, passed, trim_mode, size_trim_tol, auto_trim_tol) and returns: params,  np