code: def _finalize(
      problem, SA, Em, d, alpha, maxorder, RT, Y_em, bootstrap_idx, X, Y
  ):
      """Creates ResultDict to be returned."""
  
      # Create Sensitivity Indices Result Dictionary
      keys = (
          "Sa",
          "Sa_conf",
          "Sb",
          "Sb_conf",
          "S",
          "S_conf",
          "select",
          "Sa_sum",
          "Sa_sum_conf",
          "Sb_sum",
          "Sb_sum_conf",
          "S_sum",
          "S_sum_conf",
      )
      Si = ResultDict((k, np.zeros(Em["n"])) for k in keys)
      Si["Term"] = [None] * Em["n"]
      Si["ST"] = [
          np.nan,
      ] * Em["n"]
      Si["ST_conf"] = [
          np.nan,
      ] * Em["n"]
  
      # 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(Em["n1"]):
          if maxorder == 1:
              TS = SA["S"][r, :]
          elif maxorder == 2:
              ij = (
                  Em["n1"]
                  + np.where(np.sum(Em["c2"] == r, axis=1) == 1)[0]
              )
              TS = np.sum(SA["S"][np.append(r, ij), :], axis=0)
          elif maxorder == 3:
              ij = (
                  Em["n1"]
                  + np.where(np.sum(Em["c2"] == r, axis=1) == 1)[0]
              )
              ijk = (
                  Em["n1"]
                  + Em["n2"]
                  + np.where(np.sum(Em["c3"] == r, axis=1) == 1)[0]
              )
              TS = np.sum(
                  SA["S"][np.append(r, np.append(ij, ijk)), :], axis=0
              )
          Si["ST"][r] = np.mean(TS)
          Si["ST_conf"][r] = mult * np.std(TS)
  
      # Fill Expansion Terms
      ct = 0
      p_names = problem["names"]
  
      if maxorder > 1:
          p_c2 = Em["c2"]
          if maxorder == 3:
              p_c3 = Em["c3"]
  
      for i in range(Em["n1"]):
          Si["Term"][ct] = p_names[i]
          ct += 1
  
      for i in range(Em["n2"]):
          Si["Term"][ct] = "/".join(
              [p_names[p_c2[i, 0]], p_names[p_c2[i, 1]]]
          )
          ct += 1
  
      for i in range(Em["n3"]):
          Si["Term"][ct] = "/".join(
              [
                  p_names[p_c3[i, 0]],
                  p_names[p_c3[i, 1]],
                  p_names[p_c3[i, 2]],
              ]
          )
          ct += 1
  
      # Assign Bootstrap Results to Si Dict
      Si["Sa"] = np.mean(SA["Sa"], axis=1)
      Si["Sb"] = np.mean(SA["Sb"], axis=1)
      Si["S"] = np.mean(SA["S"], axis=1)
      Si["Sa_sum"] = np.mean(np.sum(SA["Sa"], axis=0))
      Si["Sb_sum"] = np.mean(np.sum(SA["Sb"], axis=0))
      Si["S_sum"] = np.mean(np.sum(SA["S"], axis=0))
  
      # Compute Confidence Interval
      Si["Sa_conf"] = mult * np.std(SA["Sa"], axis=1)
      Si["Sb_conf"] = mult * np.std(SA["Sb"], axis=1)
      Si["S_conf"] = mult * np.std(SA["S"], axis=1)
      Si["Sa_sum_conf"] = mult * np.std(np.sum(SA["Sa"]))
      Si["Sb_sum_conf"] = mult * np.std(np.sum(SA["Sb"]))
      Si["S_sum_conf"] = mult * np.std(np.sum(SA["S"]))
  
      # F-test # of selection to print out
      Si["select"] = Em["select"].flatten()
  
      Si["names"] = Si["Term"]
  
      # Additional data for plotting.
      Si["Em"] = Em
      Si["RT"] = RT
      Si["Y_em"] = Y_em
      Si["idx"] = bootstrap_idx
      Si["X"] = X
      Si["Y"] = Y
  
      Si.emulate = MethodType(emulate, Si)
      Si.to_df = MethodType(to_df, Si)
  
      Si._plot = Si.plot
      Si.plot = MethodType(plot, Si)
  
      if not isinstance(problem, ProblemSpec):
          Si.problem = problem
      else:
          problem.update(Si)
          problem.emulate = MethodType(emulate, problem)
  
      return Si
  
imports: from typing import Dict
  from types import MethodType
  import itertools
  import time
  import warnings
  import numpy
  from numpy.linalg import solve
  from numpy.linalg import svd
  from numpy import identity
  import pandas
  from scipy import stats, special, interpolate
  from .None import common_args
  from ..util import read_param_file, ResultDict
  from SALib.plotting.hdmr import plot
  from SALib.util.problem import ProblemSpec
label_desc: Use image node_id 11 for calling a global function with example usage: _finalize(problem, SA, Em, d, alpha, maxorder, RT, Y_em, bootstrap_idx, X, Y) and returns: Si, unknown