code: def get_top_drawdowns(returns, top=10):
      
  
      returns = returns.copy()
      df_cum = ep.cum_returns(returns, 1.0)
      running_max = np.maximum.accumulate(df_cum)
      underwater = df_cum / running_max - 1
  
      drawdowns = []
      for t in range(top):
          peak, valley, recovery = get_max_drawdown_underwater(underwater)
          # Slice out draw-down period
          if not pd.isnull(recovery):
              underwater.drop(underwater[peak: recovery].index[1:-1],
                              inplace=True)
          else:
              # drawdown has not ended yet
              underwater = underwater.loc[:peak]
  
          drawdowns.append((peak, valley, recovery))
          if (len(returns) == 0) or (len(underwater) == 0):
              break
  
      return drawdowns
docs: Finds top drawdowns, sorted by drawdown amount.
  
      Parameters
      ----------
      returns : pd.Series
          Daily returns of the strategy, noncumulative.
           - See full explanation in tears.create_full_tear_sheet.
      top : int, optional
          The amount of top drawdowns to find (default 10).
  
      Returns
      -------
      drawdowns : list
          List of drawdown peaks, valleys, and recoveries. See get_max_drawdown.