code: def rate(
      nper, pmt, pv, fv, when="end", guess=None, tol=None, maxiter=100
  ):
      """
      Compute the rate of interest per period.
  
      Parameters
      ----------
      nper : array_like
          Number of compounding periods
      pmt : array_like
          Payment
      pv : array_like
          Present value
      fv : array_like
          Future value
      when : {{'begin', 1}, {'end', 0}}, {string, int}, optional
          When payments are due ('begin' (1) or 'end' (0))
      guess : Number, optional
          Starting guess for solving the rate of interest, default 0.1
      tol : Number, optional
          Required tolerance for the solution, default 1e-6
      maxiter : int, optional
          Maximum iterations in finding the solution
  
      Notes
      -----
      The rate of interest is computed by iteratively solving the
      (non-linear) equation::
  
       fv + pv*(1+rate)**nper + pmt*(1+rate*when)/rate * ((1+rate)**nper - 1) = 0
  
      for ``rate``.
  
      References
      ----------
      Wheeler, D. A., E. Rathke, and R. Weir (Eds.) (2009, May). Open Document
      Format for Office Applications (OpenDocument)v1.2, Part 2: Recalculated
      Formula (OpenFormula) Format - Annotated Version, Pre-Draft 12.
      Organization for the Advancement of Structured Information Standards
      (OASIS). Billerica, MA, USA. [ODT Document]. Available:
      http://www.oasis-open.org/committees/documents.php?wg_abbrev=office-formula
      OpenDocument-formula-20090508.odt
  
      """
      when = _convert_when(when)
      default_type = Decimal if isinstance(pmt, Decimal) else float
  
      # Handle casting defaults to Decimal if/when pmt is a Decimal and
      # guess and/or tol are not given default values
      if guess is None:
          guess = default_type("0.1")
  
      if tol is None:
          tol = default_type("1e-6")
  
      (nper, pmt, pv, fv, when) = map(
          np.asarray, [nper, pmt, pv, fv, when]
      )
  
      rn = guess
      iterator = 0
      close = False
      while (iterator < maxiter) and not close:
          rnp1 = rn - _g_div_gp(rn, nper, pmt, pv, fv, when)
          diff = abs(rnp1 - rn)
          close = np.all(diff < tol)
          iterator += 1
          rn = rnp1
      if not close:
          # Return nan's in array of the same shape as rn
          return np.nan + rn
      else:
          return rn
  
imports: from __future__ import division, absolute_import, print_function
  from decimal import Decimal
  import functools
  import numpy
  from numpy.core import overrides
label_desc: Use image node_id 17 for calling a global function with example usage: rate(nper, pmt, pv, fv, when, guess, tol, maxiter) and returns: unknown, rn