code: def compile_function(node, globals_=None):
    
    if not isinstance(node, gast.AST):
      if not isinstance(node, six.string_types):
        raise TypeError
      node = gast.parse(node)
    if isinstance(node, gast.Module):
      for succ in node.body:
        if isinstance(succ, gast.FunctionDef):
          name = succ.name
          break
      else:
        raise ValueError('no function found')
    elif isinstance(node, gast.FunctionDef):
      name = node.name
    else:
      raise TypeError
    module = compile_file(node, globals_)
    return getattr(module, name)
docs: Convert an AST or string into a function with inspectable source.
  
    This function uses `compile_file` internally, but instead of returning the
    entire module it will return the function only.
  
    Args:
      node: A `FunctionDef` node or a `Module` node which contains at least one
          `FunctionDef` node. If a module contains multiple functions, a handle
          to the first one will be returned.
      globals_: See `compile_file`
  
    Returns:
      A handle to the compiled function.
  
    Raises:
      TypeError: If the input is not a string or AST.
      ValueError: If no function can be found.