code: def temp_pyfile(src, ext=".py"):
      """Make a temporary python file, return filename and filehandle.
  
      Parameters
      ----------
      src : string or list of strings (no need for ending newlines if list)
        Source code to be written to the file.
  
      ext : optional, string
        Extension for the generated file.
  
      Returns
      -------
      (filename, open filehandle)
        It is the caller's responsibility to close the open file and unlink it.
      """
      fname = tempfile.mkstemp(ext)[1]
      f = open(fname, "w")
      f.write(src)
      f.flush()
      return fname, f
  
imports: from __future__ import print_function
  from __future__ import absolute_import
  import atexit
  import os
  import sys
  import tempfile
  import warnings
  from warnings import warn
  from IPython.utils.decorators import undoc
  from .capture import CapturedIO, capture_output
  from .py3compat import string_types, input, PY3
label_desc: Use image node_id 2 for calling a global function with example usage: temp_pyfile(src, ext) and returns: fname,  f