code: def shrink_node(
      node, reg_param, parent_val, parent_num, cum_sum, scheme, constant
  ):
      """Shrink the tree"""
  
      is_leaf = not node.hasChildNodes()
      # if self.prediction_task == 'regression':
      val = node.nodeValue
      is_root = parent_val is None and parent_num is None
      n_samples = (
          len(node.labels)
          if (scheme != "leaf_based" or is_root)
          else parent_num
      )
  
      if is_root:
          val_new = val
  
      else:
          reg_term = (
              reg_param
              if scheme == "constant"
              else reg_param / parent_num
          )
  
          val_new = (val - parent_val) / (1 + reg_term)
  
      cum_sum += val_new
  
      if is_leaf:
          if scheme == "leaf_based":
              v = constant + (val - constant) / (
                  1 + reg_param / node.n_obs
              )
              node.nodeValue = v
          else:
              node.nodeValue = cum_sum
  
      else:
          for c in node.childNodes:
              shrink_node(
                  c,
                  reg_param,
                  val,
                  parent_num=n_samples,
                  cum_sum=cum_sum,
                  scheme=scheme,
                  constant=constant,
              )
  
      return node
  
imports: import copy
  from copy import deepcopy
  from typing import List
  from xml.dom import minidom
  from xml.etree import ElementTree
  import numpy
  import pandas
  from sklearn.base import BaseEstimator, ClassifierMixin
  from sklearn.model_selection import cross_val_score
  from sklearn.utils.validation import check_array, check_is_fitted, check_X_y
  from imodels.util.arguments import check_fit_arguments
  from ..c45_tree.c45_utils import decision, is_numeric_feature, gain, gain_ratio, get_best_split, set_as_leaf_node
  from ...util.data_util import get_clean_dataset
label_desc: Use image node_id 6 for calling a global function with example usage: shrink_node(node, reg_param, parent_val, parent_num, cum_sum, scheme, constant) and returns: node