code: def flatten(l):
      """
      Turns a nested graph of lists/tuples/other objects into a list of objects.
  
      Parameters
      ----------
      l : list/tuple/other objects
          Might be nested.
  
      Returns
      -------
      object
          A flattened list of objects.
  
      """
      if isinstance(l, (list, tuple, ValuesView)):
          rval = []
          for elem in l:
              if isinstance(elem, (list, tuple)):
                  rval.extend(flatten(elem))
              else:
                  rval.append(elem)
      else:
          return [l]
      return rval
  
file_path: Theano/theano/compile/nanguardmode.py
imports: from __future__ import absolute_import, print_function, division
  import logging
  from six.moves import StringIO
  import numpy
  import theano
  from theano import config
  import theano.tensor
  from theano.compile import Mode
  from theano.compat import ValuesView
  from .mode import get_mode
label_desc: Use image node_id 2 for calling a global function with example usage: flatten(l) and returns: rval, list