code: def beta_aligned(returns, factor_returns, risk_free=0.0):
      """Calculates beta.
  
      If they are pd.Series, expects returns and factor_returns have already
      been aligned on their labels.  If np.ndarray, these arguments should have
      the same shape.
  
      Parameters
      ----------
      returns : pd.Series or np.ndarray
          Daily returns of the strategy, noncumulative.
          - See full explanation in :func:`~empyrical.stats.cum_returns`.
      factor_returns : pd.Series or np.ndarray
           Daily noncumulative returns of the factor to which beta is
           computed. Usually a benchmark such as the market.
           - This is in the same style as returns.
      risk_free : int, float, optional
          Constant risk-free return throughout the period. For example, the
          interest rate on a three month us treasury bill.
  
      Returns
      -------
      float
          Beta.
      """
  
      if len(returns) < 2 or len(factor_returns) < 2:
          return np.nan
      # Filter out dates with np.nan as a return value
      joint = np.vstack(
          [_adjust_returns(returns, risk_free), factor_returns]
      )
      joint = joint[:, ~np.isnan(joint).any(axis=0)]
      if joint.shape[1] < 2:
          return np.nan
  
      cov = np.cov(joint, ddof=0)
  
      if np.absolute(cov[1, 1]) < 1.0e-30:
          return np.nan
  
      return cov[0, 1] / cov[1, 1]
  
imports: from __future__ import division
  from functools import wraps
  import pandas
  import numpy
  from scipy import stats
  from six import iteritems
  from empyrical.utils import nanmean, nanstd, nanmin
label_desc: Use image node_id 23 for calling a global function with example usage: beta_aligned(returns, factor_returns, risk_free) and returns: unknown, np, np, np