code: def main():
      """Main function generating a JSON file with list of NeMo collections."""
      # Parse filename.
      parser = argparse.ArgumentParser()
      parser.add_argument(
          "--filename",
          help="Name of the output JSON file",
          type=str,
          default="collections.json",
      )
      args = parser.parse_args()
  
      # Get collections directory.
      colletions_dir = os.path.dirname(nemo.collections.__file__)
      logging.info(
          "Analysing collections in `{}`".format(colletions_dir)
      )
  
      # Generate list of NeMo collections - from the list of collection subfolders.
      collections = {}
      for sub_dir in os.listdir(colletions_dir):
          # Skip cache.
          if sub_dir == "__pycache__":
              continue
          # Check if it is a directory.
          if os.path.isdir(os.path.join(colletions_dir, sub_dir)):
              collections[sub_dir] = "nemo.collections." + sub_dir
  
      output_list = []
      # Iterate over all collections.
      for key, val in collections.items():
          # Try to get module specification.
          module_spec = importlib.util.find_spec(val)
          if module_spec is None:
              logging.warning("  * Failed to process `{}`".format(val))
          else:
              try:
                  # Import the module from the module specification.
                  module = importlib.util.module_from_spec(module_spec)
                  module_spec.loader.exec_module(module)
                  # Add to list.
                  output_list.append(process_collection(key, module))
                  logging.info("  * Processed `{}`".format(val))
              except AttributeError:
                  logging.warning(
                      "  * Failed to process `{}`".format(val)
                  )
  
      # Export to JSON.
      with open(args.filename, "w", encoding="utf-8") as outfile:
          json.dump(output_list, outfile)
  
      logging.info(
          "Finshed the analysis, results exported to `{}`.".format(
              args.filename
          )
      )
  
imports: import argparse
  import importlib
  import json
  import os
  import nemo
  from nemo.utils import logging
label_desc: Use image node_id 2 for calling a global function with example usage: main() without return types