code: def enumerate_global_imports(tokens):
      
      imported_modules = []
      import_line = False
      from_import = False
      parent_module = ""
      function_count = 0
      indentation = 0
      for index, tok in enumerate(tokens):
          token_type = tok[0]
          token_string = tok[1]
          if token_type == tokenize.INDENT:
              indentation += 1
          elif token_type == tokenize.DEDENT:
              indentation -= 1
          elif token_type == tokenize.NEWLINE:
              import_line = False
              from_import = False
          elif token_type == tokenize.NAME:
              if token_string in ["def", "class"]:
                  function_count += 1
              if indentation == function_count - 1:
                  function_count -= 1
              elif function_count >= indentation:
                  if token_string == "import":
                      import_line = True
                  elif token_string == "from":
                      from_import = True
                  elif import_line:
                      if token_type == tokenize.NAME \
                          and tokens[index+1][1] != 'as':
                          if not from_import \
                              and token_string not in reserved_words:
                              if token_string not in imported_modules:
                                  if tokens[index+1][1] == '.': # module.module
                                      parent_module = token_string + '.'
                                  else:
                                      if parent_module:
                                          module_string = (
                                              parent_module + token_string)
                                          imported_modules.append(module_string)
                                          parent_module = ''
                                      else:
                                          imported_modules.append(token_string)
  
      return imported_modules
docs: Returns a list of all globally imported modules (skips modules imported
      inside of classes, methods, or functions).  Example::
  
          >>> enumerate_global_modules(tokens)
          ['sys', 'os', 'tokenize', 're']
  
      .. note::
  
          Does not enumerate imports using the 'from' or 'as' keywords.