code: def cum_returns(returns, starting_value=0, out=None):
      """
      Compute cumulative returns from simple returns.
  
      Parameters
      ----------
      returns : pd.Series, np.ndarray, or pd.DataFrame
          Returns of the strategy as a percentage, noncumulative.
           - Time series with decimal returns.
           - Example::
  
              2015-07-16   -0.012143
              2015-07-17    0.045350
              2015-07-20    0.030957
              2015-07-21    0.004902
  
           - Also accepts two dimensional data. In this case, each column is
             cumulated.
  
      starting_value : float, optional
         The starting returns.
      out : array-like, optional
          Array to use as output buffer.
          If not passed, a new array will be created.
  
      Returns
      -------
      cumulative_returns : array-like
          Series of cumulative returns.
      """
      if len(returns) < 1:
          return returns.copy()
  
      nanmask = np.isnan(returns)
      if np.any(nanmask):
          returns = returns.copy()
          returns[nanmask] = 0
  
      allocated_output = out is None
      if allocated_output:
          out = np.empty_like(returns)
  
      np.add(returns, 1, out=out)
      out.cumprod(axis=0, out=out)
  
      if starting_value == 0:
          np.subtract(out, 1, out=out)
      else:
          np.multiply(out, starting_value, out=out)
  
      if allocated_output:
          if returns.ndim == 1 and isinstance(returns, pd.Series):
              out = pd.Series(out, index=returns.index)
          elif isinstance(returns, pd.DataFrame):
              out = pd.DataFrame(
                  out,
                  index=returns.index,
                  columns=returns.columns,
              )
  
      return out
  
imports: from __future__ import division
  import math
  import pandas
  import numpy
  from math import pow
  from scipy import stats, optimize
  from six import iteritems
  from sys import float_info
  from .utils import nanmean, nanstd, nanmin, up, down, roll, rolling_window
  from .periods import ANNUALIZATION_FACTORS, APPROX_BDAYS_PER_YEAR
  from .periods import DAILY, WEEKLY, MONTHLY, QUARTERLY, YEARLY
label_desc: Use image node_id 7 for calling a global function with example usage: cum_returns(returns, starting_value, out) and returns: out, returns