code: def get_mintrace_wls_P(S: np.ndarray):
      """MinTraceOLS Reconciliation Matrix.
  
      Creates MinTraceOLS reconciliation matrix as proposed by Wickramasuriya et al.
      Depending on a weighted GLS estimator and an estimator of the covariance matrix of the coherency errors $\mathbf{W}_{h}$.
  
      $$ \mathbf{W}_{h} = \mathrm{Diag}(\mathbf{S} \mathbb{1}_{[b]})$$
  
      $$\mathbf{P}_{\\text{MinTraceWLS}}=\\left(\mathbf{S}^{\intercal}\mathbf{W}_{h}\mathbf{S}\\right)^{-1}
      \mathbf{S}^{\intercal}\mathbf{W}^{-1}_{h}$$
  
      **Parameters:**<br>
      `S`: Summing matrix of size (`base`, `bottom`).<br>
  
      **Returns:**<br>
      `P`: Reconciliation matrix of size (`bottom`, `base`).<br>
  
      **References:**<br>
      - [Wickramasuriya, S.L., Turlach, B.A. & Hyndman, R.J. (2020). \"Optimal non-negative
      forecast reconciliation". Stat Comput 30, 1167–1182,
      https://doi.org/10.1007/s11222-020-09930-0](https://robjhyndman.com/publications/nnmint/).
      """
      n_hiers, n_bottom = S.shape
      n_agg = n_hiers - n_bottom
  
      W = np.diag(S @ np.ones((n_bottom,)))
  
      # We compute reconciliation matrix with
      # Equation 10 from https://robjhyndman.com/papers/MinT.pdf
      A = S[:n_agg, :]
      U = np.hstack((np.eye(n_agg), -A)).T
      J = np.hstack((np.zeros((n_bottom, n_agg)), np.eye(n_bottom)))
      P = J - (J @ W @ U) @ np.linalg.pinv(U.T @ W @ U) @ U.T
      return P
  
file_path: neuralforecast/neuralforecast/models/hint.py
imports: from typing import Optional
  import numpy
  import torch
label_desc: Use image node_id 3 for calling a global function with example usage: get_mintrace_wls_P(S) and returns: P