code: def mask_returns_to_period(self, daily_returns, trading_days):
      if isinstance(daily_returns, list):
          returns = pd.Series(
              [x.returns for x in daily_returns],
              index=[x.date for x in daily_returns],
          )
      else:  # otherwise we're receiving an index already
          returns = daily_returns
  
      trade_day_mask = returns.index.normalize().isin(trading_days)
  
      mask = (
          (returns.index >= self._start_session)
          & (returns.index <= self._end_session)
          & trade_day_mask
      )
  
      returns = returns[mask]
      return returns
  
file_path: catalyst/catalyst/finance/risk/period.py
imports: import functools
  import warnings
  import logbook
  from six import iteritems
  import numpy
  import pandas
  from .None import risk
  from .risk import check_entry
  from empyrical import alpha_beta_aligned, annual_volatility, downside_risk, information_ratio, sharpe_ratio, sortino_ratio
  from catalyst.patches.stats import max_drawdown, cum_returns
  from catalyst.constants import LOG_LEVEL
label_desc: Use image node_id 5 for calling the RiskMetricsPeriod obj's underlying member method code with example usage: obj.mask_returns_to_period(daily_returns, trading_days) and returns: returns