code: def find_dependencies(mode, algo):
      if algo in ["MusicExtractor", "FreesoundExtractor"]:
          # FIXME These are special algorithms that instantiate all dependencies
          # inside compute(). Ideally, they should be rewritten to do that in
          # configure() methods. Feeding a test audiofile as an input.
          print("Running compute() for", algo)
  
          code = """
  import essentia.%s as es
  import essentia
  from essentia.pytools.io import test_audiofile
  test_audio = test_audiofile()
  
  essentia.log.infoActive = True
  essentia.log.debugLevels += essentia.EFactory
  es.%s()(test_audio)
  """ % (
              mode,
              algo,
          )
      else:
          code = """
  import essentia.%s as es
  import essentia
  
  essentia.log.infoActive = True
  essentia.log.debugLevels += essentia.EFactory
  loader = es.%s()
  """ % (
              mode,
              algo,
          )
  
      proc = subprocess.Popen(
          [sys.executable, "-c", code], stderr=subprocess.PIPE
      )
      stderr = proc.communicate()[1].decode("utf8").split("\n")
      exit_code = proc.wait()
  
      if exit_code != 0:
          raise Exception(
              f"Python script running {algo} algorithms failed with error:\n"
              + "-" * 80
              + "\n"
              + "\n".join(stderr)
          )
  
      # function to assign nested dict elements by a list of nested keys
      def set_val(d, keys, val):
          from functools import reduce  # Python 3 compatibility
  
          reduce(lambda x, y: x[y], keys[:-1], d)[keys[-1]] = val
  
      algos = []
      lines = []
      tree = {}
      previous_key = []
      previous_indent = -8
  
      # NOTE: the code relies heavily on indentification of output in Essentia's logger
      for line in stderr:
          if line.startswith("[Factory   ] "):
              line = line.replace("[Factory   ] ", "")
              if line.count("Streaming: Creating algorithm: "):
                  tab, a = line.split("Streaming: Creating algorithm: ")
                  m = "streaming"
              elif line.count("Standard : Creating algorithm: "):
                  tab, a = line.split("Standard : Creating algorithm: ")
                  m = "standard"
              else:
                  continue
  
              lines.append(line)
              algos.append((m, a))
  
              indent = len(tab)
  
              if indent < previous_indent:
                  previous_key = previous_key[:-2]
              if indent == previous_indent:
                  previous_key = previous_key[:-1]
  
              set_val(tree, previous_key + [(m, a)], {})
              previous_key += [(m, a)]
  
              previous_indent = indent
  
      algos = sorted(list(set(algos)))
      # algos = sorted(list(set(algos) - set([(mode, algo)])))
      return algos, tree, lines
  
file_path: essentia/src/examples/python/show_algo_dependencies.py
imports: import sys
  import subprocess
  import essentia.standard
  import essentia.streaming
  import yaml
  import argparse
label_desc: Use image node_id 1 for calling a global function with example usage: find_dependencies(mode, algo) and returns: algos,  tree,  lines