code: def decompose_portofolio_weight(stock_weight_df, stock_group_df):
      """decompose_portofolio_weight
  
      '''
      :param stock_weight_df: a pandas dataframe to describe the portofolio by weight.
                      every row corresponds to a  day
                      every column corresponds to a stock.
                      Here is an example below.
                      code        SH600004  SH600006  SH600017  SH600022  SH600026  SH600037  \
                      date
                      2016-01-05  0.001543  0.001570  0.002732  0.001320  0.003000       NaN
                      2016-01-06  0.001538  0.001569  0.002770  0.001417  0.002945       NaN
                      ....
      :param stock_group_df: a pandas dataframe to describe  the stock group.
                      every row corresponds to a  day
                      every column corresponds to a stock.
                      the value in the cell repreponds the group id.
                      Here is a example by for stock_group_df for industry. The value is the industry code
                      instrument  SH600000  SH600004  SH600005  SH600006  SH600007  SH600008  \
                      datetime
                      2016-01-05  801780.0  801170.0  801040.0  801880.0  801180.0  801160.0
                      2016-01-06  801780.0  801170.0  801040.0  801880.0  801180.0  801160.0
                      ...
      :return:        Two dict will be returned.  The group_weight and the stock_weight_in_group.
                      The key is the group. The value is a Series or Dataframe to describe the weight of group or weight of stock
      """
      all_group = np.unique(stock_group_df.values.flatten())
      all_group = all_group[~np.isnan(all_group)]
  
      group_weight = {}
      stock_weight_in_group = {}
      for group_key in all_group:
          group_mask = stock_group_df == group_key
          group_weight[group_key] = stock_weight_df[group_mask].sum(
              axis=1
          )
          stock_weight_in_group[group_key] = stock_weight_df[
              group_mask
          ].divide(group_weight[group_key], axis=0)
      return group_weight, stock_weight_in_group
  
file_path: qlib/qlib/backtest/profit_attribution.py
imports: import datetime
  from pathlib import Path
  import numpy
  import pandas
  from ..config import C
  from ..data import D
  from .position import Position
label_desc: Use image node_id 3 for calling a global function with example usage: decompose_portofolio_weight(stock_weight_df, stock_group_df) and returns: group_weight,  stock_weight_in_group