docs: def intervals(weights):
      """
      Extract intervals where generics are composed of different tradeable
      instruments.
  
      Parameters
      ----------
      weights: DataFrame or dict
          A DataFrame or dictionary of DataFrames with columns representing
          generics and a MultiIndex of date and contract. Values represent
          weights on tradeables for each generic.
  
      Returns
      -------
      A DataFrame with [columns]
      ['contract', 'generic', 'start_date', 'end_date']
  
      """
      intrvls = []
      if isinstance(weights, dict):
          for root in weights:
              wts = weights[root]
              intrvls.append(_intervals(wts))
          intrvls = pd.concat(intrvls, axis=0)
      else:
          intrvls = _intervals(weights)
      intrvls = intrvls.reset_index(drop=True)
      return intrvls