docstr: Returns the G matrix given a specified reconciliation method.
docstr_tok: ["Returns","the","G","matrix","given","a","specified","reconciliation","method","."]
code: def get_matrices(series: Optional[TimeSeries], method: str):
      """Returns the G matrix given a specified reconciliation method."""
      S = _get_summation_matrix(series)
      if method == "ols":
          # G = inv(S'*S)*S'
          G = np.linalg.inv(S.T @ S) @ S.T
          return S, G
      elif method == "wls_struct":
          # Wh is a diagonal matrix with entry i,i being the sum of row i of S_mat
          Wh = np.diag(np.sum(S, axis=1))
      elif method == "wls_var":
          # In this case we assume that series contains the residuals of some forecasts
          MinTReconciliator._assert_deterministic(series)
          et2 = series.values(copy=False) ** 2  # squared residuals
          # Wh diagonal is mean squared residual over time:
          Wh = np.diag(et2.mean(axis=0))
      elif method == "wls_val":
          # Wh is a diagonal matrix with entry i,i being the average value of the corresponding time series
          quantities = (
              series.all_values(copy=False).mean(axis=2).mean(axis=0)
          )
          Wh = np.diag(np.array(quantities))
      elif method == "mint_cov":
          MinTReconciliator._assert_deterministic(series)
          Wh = np.cov(
              series.values(copy=False).T
          )  # + 1e-3 * np.eye(len(series.components))
      else:
          raise_if_not(False, f"Unknown method: {method}")
  
      Wh_inv = np.linalg.inv(Wh)
      G = np.linalg.inv(S.T @ Wh_inv @ S) @ S.T @ Wh_inv
      return S, G
  
imports: from typing import Any, Mapping, Optional
  import numpy
  from darts.dataprocessing.transformers import BaseDataTransformer, FittableDataTransformer
  from darts.timeseries import TimeSeries
  from darts.utils.utils import raise_if_not
label_desc: Use image node_id 5 for calling the MinTReconciliator obj's underlying member method code with example usage: obj.get_matrices(series, method) and returns: S,  G, S,  G