code: def nper(rate, pmt, pv, fv=0, when="end"):
      """
      Compute the number of periodic payments.
  
      :class:`decimal.Decimal` type is not supported.
  
      Parameters
      ----------
      rate : array_like
          Rate of interest (per period)
      pmt : array_like
          Payment
      pv : array_like
          Present value
      fv : array_like, optional
          Future value
      when : {{'begin', 1}, {'end', 0}}, {string, int}, optional
          When payments are due ('begin' (1) or 'end' (0))
  
      Notes
      -----
      The number of periods ``nper`` is computed by solving the equation::
  
       fv + pv*(1+rate)**nper + pmt*(1+rate*when)/rate*((1+rate)**nper-1) = 0
  
      but if ``rate = 0`` then::
  
       fv + pv + pmt*nper = 0
  
      Examples
      --------
      If you only had $150/month to pay towards the loan, how long would it take
      to pay-off a loan of $8,000 at 7% annual interest?
  
      >>> print(round(np.nper(0.07/12, -150, 8000), 5))
      64.07335
  
      So, over 64 months would be required to pay off the loan.
  
      The same analysis could be done with several different interest rates
      and/or payments and/or total amounts to produce an entire table.
  
      >>> np.nper(*(np.ogrid[0.07/12: 0.08/12: 0.01/12,
      ...                    -150   : -99     : 50    ,
      ...                    8000   : 9001    : 1000]))
      array([[[  64.07334877,   74.06368256],
              [ 108.07548412,  127.99022654]],
             [[  66.12443902,   76.87897353],
              [ 114.70165583,  137.90124779]]])
  
      """
      when = _convert_when(when)
      (rate, pmt, pv, fv, when) = map(
          np.asarray, [rate, pmt, pv, fv, when]
      )
  
      use_zero_rate = False
      with np.errstate(divide="raise"):
          try:
              z = pmt * (1 + rate * when) / rate
          except FloatingPointError:
              use_zero_rate = True
  
      if use_zero_rate:
          return (-fv + pv) / pmt
      else:
          A = -(fv + pv) / (pmt + 0)
          B = np.log((-fv + z) / (pv + z)) / np.log(1 + rate)
          return np.where(rate == 0, A, B)
  
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 7 for calling a global function with example usage: nper(rate, pmt, pv, fv, when) and returns: unknown, np