code: def getterms(expression):
      """Return the all instances of Term in an expression.
  
      Examples
      --------
      >>> x, y, z = [Term(l) for l in 'xyz']
      >>> f = Formula([x,y,z])
      >>> getterms(f)
      [x, y, z]
      >>> getterms(f.mean)
      [x, y, z]
      """
      atoms = set()
      expression = np.array(expression)
      if expression.shape == ():
          expression = expression.reshape((1,))
      if expression.ndim > 1:
          expression = expression.reshape((np.prod(expression.shape),))
      for e in expression:
          atoms = atoms.union(e.atoms())
      terms = []
      for atom in atoms:
          if is_term(atom):
              terms.append(atom)
      terms.sort(key=default_sort_key)
      return terms
  
imports: import itertools
  import warnings
  from string import ascii_letters, digits
  import numpy
  import sympy
  from scipy.linalg import pinv
  from sympy import Dummy, default_sort_key
  from sympy.utilities.lambdify import implemented_function, lambdify
  from nipy.algorithms.utils.matrices import full_rank, matrix_rank
  from nipy.utils import VisibleDeprecationWarning, _NoValue
label_desc: Use image node_id 6 for calling a global function with example usage: getterms(expression) and returns: terms