code: def generate_toy_risk_model_output(
      start_date="2017-01-01", periods=10, num_styles=2
  ):
      """
      Generate toy risk model output.
  
      Parameters
      ----------
      start_date : str
          date to start generating toy data
      periods : int
          number of days for which to generate toy data
  
      Returns
      -------
      tuple of (returns, factor_returns, positions, factor_loadings)
      returns : pd.DataFrame
      factor_returns : pd.DataFrame
      """
      dts = pd.date_range(start_date, periods=periods)
      np.random.seed(123)
      tickers = ["AAPL", "TLT", "XOM"]
      styles = ["factor{}".format(i) for i in range(num_styles)]
  
      returns = (
          pd.Series(index=dts, data=np.random.randn(periods)) / 100
      )
  
      factor_returns = (
          pd.DataFrame(
              columns=styles,
              index=dts,
              data=np.random.randn(periods, len(styles)),
          )
          / 100
      )
  
      arrays = [dts, tickers]
      index = pd.MultiIndex.from_product(arrays, names=["dt", "ticker"])
  
      positions = pd.DataFrame(
          columns=tickers,
          index=dts,
          data=np.random.randint(100, size=(periods, len(tickers))),
      )
      positions["cash"] = np.zeros(periods)
  
      factor_loadings = pd.DataFrame(
          columns=styles,
          index=index,
          data=np.random.randn(periods * len(tickers), len(styles)),
      )
  
      return returns, positions, factor_returns, factor_loadings
  
file_path: pyfolio/pyfolio/tests/test_perf_attrib.py
imports: import numpy
  import pandas
  import unittest
  import warnings
  import empyrical
  from pyfolio.perf_attrib import perf_attrib, create_perf_attrib_stats, _cumulative_returns_less_costs
label_desc: Use image node_id 2 for calling a global function with example usage: generate_toy_risk_model_output(start_date, periods, num_styles) and returns: returns,  positions,  factor_returns,  factor_loadings