code: def _first_order(B1, Y_res, C1, R, n1, m1, maxiter, lambdax):
      """Compute first order sensitivities."""
      Y_i = np.empty((R, n1))  # Initialize 1st order contributions
      T1 = np.empty((m1, R, n1))  # Initialize T(emporary) matrix - 1st
      it = 0  # Initialize iteration counter
  
      lam_eye_m1 = lambdax * identity(m1)
  
      # Avoid memory allocations by using temporary store
      B1_j = np.empty(B1[:, :, 0].shape)
      B11 = np.empty((m1, m1))
  
      # First order individual estimation
      for j in range(n1):
          # Regularized least squares inversion ( minimize || C1 ||_2 )
          B1_j[:, :] = B1[:, :, j]
          B11[:, :] = B1_j.T @ B1_j
  
          # if it is ill-conditioned matrix, the default value is zero
          if np.all(svd(B11)[1]):  # sigma, diagonal matrix, from svd
              T1[:, :, j] = lin_solve(B11 + lam_eye_m1, B1_j.T)
  
          C1[:, j] = T1[:, :, j] @ Y_res
          Y_i[:, j] = B1_j @ C1[:, j]
  
      # Backfitting Method
      var1b_old = np.sum(np.square(C1), axis=0)
      varmax = 1
      while (varmax > 1e-3) and (it < maxiter):
          for j in range(n1):
              Y_r = Y_res
              for z in range(n1):
                  if j != z:
                      Y_r = Y_r - B1[:, :, z] @ C1[:, z]
  
              C1[:, j] = T1[:, :, j] @ Y_r
  
          var1b_new = np.sum(np.square(C1), axis=0)
          varmax = np.max(np.absolute(var1b_new - var1b_old))
          var1b_old = var1b_new
          it += 1
  
      # Now compute first-order terms
      for j in range(n1):
          Y_i[:, j] = B1[:, :, j] @ C1[:, j]
  
          # Subtract each first order term from residuals
          Y_res = Y_res - Y_i[:, j]
  
      return (Y_i, Y_res, C1)
  
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 6 for calling a global function with example usage: _first_order(B1, Y_res, C1, R, n1, m1, maxiter, lambdax) and returns: Y_i,  Y_res,  C1