code: def inf_to_nan(func):
      """Decorate function to return nan if it returns inf"""
  
      def wrap(*a, **kw):
          v = func(*a, **kw)
          if not np.isfinite(v):
              return np.nan
          return v
  
      return wrap
  
imports: from __future__ import division, print_function, absolute_import
  import os
  import sys
  import time
  import numpy
  from numpy.testing import assert_
  from scipy._lib.six import reraise
  from scipy.special._testutils import assert_func_equal
label_desc: Use image node_id 9 for calling a global function with example usage: inf_to_nan(func) and returns: wrap, v, np