code: def _get_g_matrix_wls_str(X):
      """Reconciliation "G" matrix for the weighted least squares (structural) method.
  
      Reconciliation methods require the G matrix. The G matrix is used to re-define
      base forecasts for the entire hierarchy to the bottom-level only before
      summation using the S matrix.
  
      Please refer to [1]_ for further information.
  
      Parameters
      ----------
      X :  Panel of mtype pd_multiindex_hier
  
      Returns
      -------
      g_wls_str : pd.DataFrame with rows equal to the number of bottom level nodes
          only, i.e. with no aggregate nodes, and columns equal to the number of
          unique nodes in the hierarchy. The matrix indexes is inherited from the
          summation matrix.
  
      References
      ----------
      .. [1] https://otexts.com/fpp3/hierarchical.html
      """
      # this is similar to the ols except we have a new matrix W
      smat = _get_s_matrix(X)
  
      diag_data = np.diag(smat.sum(axis=1).values)
      w_mat = pd.DataFrame(
          diag_data, index=smat.index, columns=smat.index
      )
  
      g_wls_str = pd.DataFrame(
          np.dot(
              inv(np.dot(np.transpose(smat), np.dot(w_mat, smat))),
              np.dot(np.transpose(smat), w_mat),
          )
      )
      # set indexes of matrix
      g_wls_str = g_wls_str.transpose()
      g_wls_str = g_wls_str.set_index(smat.index)
      g_wls_str.columns = smat.columns
      g_wls_str = g_wls_str.transpose()
  
      return g_wls_str
  
imports: import numpy
  import pandas
  from numpy.linalg import inv
  from sktime.transformations.base import BaseTransformer
  from sktime.transformations.hierarchical.aggregate import _check_index_no_total
  from sktime.utils.warnings import warn
label_desc: Use image node_id 4 for calling a global function with example usage: _get_g_matrix_wls_str(X) and returns: g_wls_str