code: def get_benchmark_weight(
      bench,
      start_date=None,
      end_date=None,
      path=None,
      freq="day",
  ):
      """get_benchmark_weight
  
      get the stock weight distribution of the benchmark
  
      :param bench:
      :param start_date:
      :param end_date:
      :param path:
      :param freq:
  
      :return: The weight distribution of the the benchmark described by a pandas dataframe
               Every row corresponds to a trading day.
               Every column corresponds to a stock.
               Every cell represents the strategy.
  
      """
      if not path:
          path = (
              Path(C.dpm.get_data_uri(freq)).expanduser()
              / "raw"
              / "AIndexMembers"
              / "weights.csv"
          )
      # TODO: the storage of weights should be implemented in a more elegent way
      # TODO: The benchmark is not consistent with the filename in instruments.
      bench_weight_df = pd.read_csv(
          path, usecols=["code", "date", "index", "weight"]
      )
      bench_weight_df = bench_weight_df[
          bench_weight_df["index"] == bench
      ]
      bench_weight_df["date"] = pd.to_datetime(bench_weight_df["date"])
      if start_date is not None:
          bench_weight_df = bench_weight_df[
              bench_weight_df.date >= start_date
          ]
      if end_date is not None:
          bench_weight_df = bench_weight_df[
              bench_weight_df.date <= end_date
          ]
      bench_stock_weight = (
          bench_weight_df.pivot_table(
              index="date", columns="code", values="weight"
          )
          / 100.0
      )
      return bench_stock_weight
  
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 1 for calling a global function with example usage: get_benchmark_weight(bench, start_date, end_date, path, freq) and returns: bench_stock_weight