code: def _second_order(b_m2, Y_res, max_iter, l2_penalty, hdmr, t):
      """Sequential determination of second-order component functions.
      First, it computes component functions via ridge regression, i.e.
      fitting model inputs/features to the model output. Later, it takes
      advantage of backfitting algorithm to satisfy hierarchical orthogonality.
      Backfitting algorithm does not guarantee the hierarchical orthogonality.
      We suggest to set extended base option to `True` for those who want to
      guaranteed functional ANOVA expansion.
  
      Parameters
      ----------
      b_m2 : numpy.array
          Basis matrix for second-order component functions
      Y_res : numpy.array
          Residual model output
      max_iter : int
          Maximum number of iteration used in backfitting algorithm
      l2_penalty : float
          Penalty term for ridge regression
      hdmr : namedtuple
          Core parameters of hdmr expansion
      t : int
          bootstrap iteration
  
      Returns
      -------
      Y_res : numpy.array
          Residual model output
      """
      # Temporary second order component matrix
      Y_ij = np.empty((hdmr.subset, hdmr.nc2))
      # To increase readibility
      n2 = hdmr.nt2
      # Initialize iteration counter
      iter = 0
      # L2 Penalty
      lambda_eye = l2_penalty * np.identity(n2)
      for i in range(hdmr.nc2):
          try:
              # Left hand side
              a = (
                  b_m2[:, i * n2 : n2 * (i + 1)].T
                  @ b_m2[:, i * n2 : n2 * (i + 1)]
              ) / hdmr.subset
              # Adding L2 Penalty (Ridge Regression)
              a += lambda_eye
              # Right hand side
              b = (
                  b_m2[:, i * n2 : n2 * (i + 1)].T @ Y_res
              ) / hdmr.subset
              # Solution
              hdmr.x[
                  hdmr.tnt1 + i * n2 : hdmr.tnt1 + n2 * (i + 1), t
              ] = solve(a, b)
              # Component functions
              Y_ij[:, i] = (
                  b_m2[:, i * n2 : n2 * (i + 1)]
                  @ hdmr.x[
                      hdmr.tnt1 + i * n2 : hdmr.tnt1 + n2 * (i + 1), t
                  ]
              )
          except LinAlgError:
              raise LinAlgError(
                  "Second Order: Least-square regression did not converge. Try increasing L2 penalty term"
              )
  
      var_old = np.square(hdmr.x[hdmr.tnt1 : hdmr.tnt1 + hdmr.tnt2, t])
      # Backfitting method
      while True:
          for i in range(hdmr.nc2):
              z = list(range(hdmr.nc2))
              z.remove(i)
              Y_r = Y_res - np.sum(Y_ij[:, z], axis=1)
              # Left hand side
              a = (
                  b_m2[:, i * n2 : n2 * (i + 1)].T
                  @ b_m2[:, i * n2 : n2 * (i + 1)]
              ) / hdmr.subset
              # Right hand side
              b = (b_m2[:, i * n2 : n2 * (i + 1)].T @ Y_r) / hdmr.subset
              # Solution
              hdmr.x[
                  hdmr.tnt1 + i * n2 : hdmr.tnt1 + n2 * (i + 1), t
              ] = solve(a, b)
              # Component functions
              Y_ij[:, i] = (
                  b_m2[:, i * n2 : n2 * (i + 1)]
                  @ hdmr.x[
                      hdmr.tnt1 + i * n2 : hdmr.tnt1 + n2 * (i + 1), t
                  ]
              )
  
          var_max = np.absolute(
              var_old
              - np.square(hdmr.x[hdmr.tnt1 : hdmr.tnt1 + hdmr.tnt2, t])
          ).max()
          iter += 1
  
          if (var_max < 1e-4) or (iter > max_iter):
              break
  
          var_old = np.square(
              hdmr.x[hdmr.tnt1 : hdmr.tnt1 + hdmr.tnt2, t]
          )
  
      return Y_res - np.sum(Y_ij, axis=1)
  
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 11 for calling a global function with example usage: _second_order(b_m2, Y_res, max_iter, l2_penalty, hdmr, t) and returns: unknown