code: def walk(top, topdown=True, onerror=None, followlinks=False, depth=0):
      """Generate the file names in a directory tree by walking the tree either top-down or bottom-up.
      For each directory in the tree rooted at directory top (including top itself), it yields a 4-tuple
      (depth, dirpath, dirnames, filenames).
  
      Parameters
      ----------
      top : str
          Root directory.
      topdown : bool, optional
          If True - you can modify dirnames in-place.
      onerror : function, optional
          Some function, will be called with one argument, an OSError instance.
          It can report the error to continue with the walk, or raise the exception to abort the walk.
          Note that the filename is available as the filename attribute of the exception object.
      followlinks : bool, optional
          If True - visit directories pointed to by symlinks, on systems that support them.
      depth : int, optional
          Height of file-tree, don't pass it manually (this used as accumulator for recursion).
  
      Notes
      -----
      This is a mostly copied version of `os.walk` from the Python 2 source code.
      The only difference is that it returns the depth in the directory tree structure
      at which each yield is taking place.
  
      Yields
      ------
      (int, str, list of str, list of str)
          Depth, current path, visited directories, visited non-directories.
  
      See Also
      --------
      `os.walk documentation <https://docs.python.org/2/library/os.html#os.walk>`_
  
      """
      islink, join, isdir = os.path.islink, os.path.join, os.path.isdir
  
      try:
          # Should be O(1) since it's probably just reading your filesystem journal
          names = os.listdir(top)
      except OSError as err:
          if onerror is not None:
              onerror(err)
          return
  
      dirs, nondirs = [], []
  
      # O(n) where n = number of files in the directory
      for name in names:
          if isdir(join(top, name)):
              dirs.append(name)
          else:
              nondirs.append(name)
  
      if topdown:
          yield depth, top, dirs, nondirs
  
      # Again O(n), where n = number of directories in the directory
      for name in dirs:
          new_path = join(top, name)
          if followlinks or not islink(new_path):
              # Generator so besides the recursive `walk()` call, no additional cost here.
              for x in walk(
                  new_path, topdown, onerror, followlinks, depth + 1
              ):
                  yield x
      if not topdown:
          yield depth, top, dirs, nondirs
  
imports: from __future__ import with_statement
  import logging
  import os
  import random
  import re
  import sys
  from gensim import interfaces, utils
  from gensim.corpora.dictionary import Dictionary
  from gensim.parsing.preprocessing import remove_stopword_tokens, remove_short_tokens, lower_to_unicode, strip_multiple_whitespaces
  from gensim.utils import deaccent, simple_tokenize
  from smart_open import open
label_desc: Use image node_id 1 for calling a global function with example usage: walk(top, topdown, onerror, followlinks, depth) without return types