code: def _wls_fit(data, mask, X, step=int(1e4)):
      """Estimate the model parameters using weighted least squares with the
      signal magnitudes as weights.
  
      Parameters
      ----------
      data : numpy.ndarray
          Array of shape (..., number of acquisitions).
      mask : numpy.ndarray
          Array with the same shape as the data array of a single acquisition.
      X : numpy.ndarray
          Design matrix of shape (number of acquisitions, 28).
      step : int, optional
          The number of voxels over which the fit is calculated simultaneously.
  
      Returns
      -------
      params : numpy.ndarray
          Array of shape (..., 28) containing the estimated model parameters.
          Element 0 is the natural logarithm of the estimated signal without
          diffusion-weighting, elements 1-6 are the estimated diffusion tensor
          elements in Voigt notation, and elements 7-27 are the estimated
          covariance tensor elements in Voigt notation.
      """
      params = np.zeros((np.prod(mask.shape), 28)) * np.nan
      data_masked = data[mask]
      size = len(data_masked)
      if step >= size:  # Fit over all data simultaneously
          S = np.log(data_masked)[..., np.newaxis]
          C = data_masked[:, np.newaxis, :]
          B = X.T * C
          A = np.linalg.pinv(B @ X)
          params_masked = (A @ B @ S)[..., 0]
      else:  # Iterate over data
          params_masked = np.zeros((size, 28))
          for i in range(0, size, step):
              S = np.log(data_masked[i : i + step])[..., np.newaxis]
              C = data_masked[i : i + step][:, np.newaxis, :]
              B = X.T * C
              A = np.linalg.pinv(B @ X)
              params_masked[i : i + step] = (A @ B @ S)[..., 0]
      params[np.where(mask.ravel())] = params_masked
      params = params.reshape((mask.shape + (28,)))
      return params
  
imports: from warnings import warn
  import numpy
  from dipy.reconst.base import ReconstModel
  from dipy.reconst.dti import auto_attr
  from dipy.utils.optpkg import optional_package
label_desc: Use image node_id 11 for calling a global function with example usage: _wls_fit(data, mask, X, step) and returns: params