code: def _d_morph(b_m, cost, Y_idx, subset, hdmr):
      """D-Morph Regression finds the best solution that aligns with the cost
      matrix. Cost matrix in this case represents the hierarchical orthogonality
      between component functions.
  
      Parameters
      ----------
      b_m : numpy.array
          Basis matrix for all component functions
      cost : numpy.array
          Cost matrix that satisfies hierarchical orthogonality
      Y_idx : numpy.array
          Model output for a single bootstrap iteration
      subset : int
          Number of subsamples
      hdmr : namedtuple
          Core parameters of hdmr expansion
  
      Returns
      -------
      soltn : numpy.array
          D-MORPH solution
  
      Notes
      -----
      Detailed information about D-Morph Regression can be found at
      .. [1] Li, G., Rey-de-Castro, R. & Rabitz, H. D-MORPH regression for modeling
          with fewer unknown parameters than observation data.
          J Math Chem 50, 1747–1764 (2012). https://doi.org/10.1007/s10910-012-0004-z
      """
      # Left Matrix Multiplication with the transpose of cost matrix
      a = (b_m.T @ b_m) / subset  # LHS
      b = (b_m.T @ Y_idx) / subset  # RHS
      try:
          # Pseudo-Inverse of LHS
          a_pinv = pinv(a, hermitian=True)
          rank = matrix_rank(a)
          # Least-Square Solution
          x = a_pinv @ b
          # Projection Matrix
          pr = np.eye(hdmr.a_tnt) - (a_pinv @ a)
          pb = pr @ cost
          U, _, Vh = svd(pb)
      except LinAlgError:
          raise LinAlgError("D-Morph: Pseudo-Inverse did not converge")
  
      nullity = min(b_m.shape) - rank
      V = Vh.T
      U = np.delete(U, range(0, nullity), axis=1)
      V = np.delete(V, range(0, nullity), axis=1)
  
      # D-Morph Regression Solution
      soltn = V @ pinv(U.T @ V) @ U.T @ x
  
      return soltn
  
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 9 for calling a global function with example usage: _d_morph(b_m, cost, Y_idx, subset, hdmr) and returns: soltn