code: def _finalize(hdmr, Si, alpha, return_emulator):
      """Final processing of sensivity analysis. Calculates confidence interval
      using statistical analysis.
  
      Parameters
      ----------
      hdmr : namedtuple
          Core parameters of hdmr expansion
      Si : ResultDict
          Sensitivity Indices
      alpha : float
          Significance level
      return_emulator : bool
          Whether to attach emulator to the Si ResultDict
  
      Returns
      -------
      Si : ResultDict
          Sensitivity Indices
      """
  
      # Z score
      def z(p):
          return (-1) * np.sqrt(2) * special.erfcinv(p * 2)
  
      # Multiplier for confidence interval
      mult = z(alpha + (1 - alpha) / 2)
  
      # Compute the total sensitivity of each parameter/coefficient
      for r in range(hdmr.d):
          if hdmr.max_order == 1:
              TS = hdmr.S[r, :]
          elif hdmr.max_order == 2:
              ij = (
                  hdmr.d
                  + np.where(np.sum(hdmr.beta == r, axis=1) == 1)[0]
              )
              TS = np.sum(Si["S"][np.append(r, ij), :], axis=0)
          elif hdmr.max_order == 3:
              ij = (
                  hdmr.d
                  + np.where(np.sum(hdmr.beta == r, axis=1) == 1)[0]
              )
              ijk = (
                  hdmr.d
                  + hdmr.nc2
                  + np.where(np.sum(hdmr.nc3 == r, axis=1) == 1)[0]
              )
              TS = np.sum(
                  Si["S"][np.append(r, np.append(ij, ijk)), :], axis=0
              )
          Si["ST"][r] = np.mean(TS)
          Si["ST_conf"][r] = mult * np.std(TS)
  
      # Compute Confidence Interval
      Si["Sa_conf"] = mult * np.std(Si["Sa"], axis=1)
      Si["Sb_conf"] = mult * np.std(Si["Sb"], axis=1)
      Si["S_conf"] = mult * np.std(Si["S"], axis=1)
      Si["Sa_sum_conf"] = mult * np.std(np.sum(Si["Sa"]))
      Si["Sb_sum_conf"] = mult * np.std(np.sum(Si["Sb"]))
      Si["S_sum_conf"] = mult * np.std(np.sum(Si["S"]))
  
      # Assign Bootstrap Results to Si Dict
      Si["Sa"] = np.mean(Si["Sa"], axis=1)
      Si["Sb"] = np.mean(Si["Sb"], axis=1)
      Si["S"] = np.mean(Si["S"], axis=1)
      Si["Sa_sum"] = np.mean(np.sum(Si["Sa"], axis=0))
      Si["Sb_sum"] = np.mean(np.sum(Si["Sb"], axis=0))
      Si["S_sum"] = np.mean(np.sum(Si["S"], axis=0))
  
      # F-test number of selection to print out
      Si["Signf"] = 100 * Si["Signf"].mean(axis=1)
  
      # Bind emulator method to the ResultDict
      if return_emulator:
          Si["hdmr"] = hdmr
          Si.emulate = MethodType(emulate, Si)
  
      # Bind Pandas Dataframe conversion to the ResultDict
      Si.to_df = MethodType(to_df, Si)
  
      return Si
  
imports: import math
  import warnings
  from typing import Dict, Tuple
  from types import MethodType
  from itertools import combinations, product
  from collections import defaultdict, namedtuple
  import numpy
  from pandas import DataFrame
  from numpy.linalg import det, pinv, matrix_rank
  from scipy.linalg import svd, LinAlgError, solve
  from scipy import stats, special
  from .None import common_args
  from ..util import read_param_file, ResultDict
label_desc: Use image node_id 16 for calling a global function with example usage: _finalize(hdmr, Si, alpha, return_emulator) and returns: Si, unknown