code: def main():
      """Main function analysing the indicated NeMo collection and generating a JSON file with module descriptions."""
      # Parse filename.
      parser = argparse.ArgumentParser()
      parser.add_argument(
          "--collection", help="ID of the collection", type=str
      )
      parser.add_argument(
          "--filename",
          help="Name of the output JSON file",
          type=str,
          default="modules.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
  
      # Check the collection.
      if args.collection not in collections.keys():
          logging.error(
              "Coudn't process the incidated `{}` collection".format(
                  args.collection
              )
          )
          logging.info(
              "Please select one of the existing collections using `--collection [{}]`".format(
                  "|".join(collections)
              )
          )
          exit(-1)
  
      # Load the collection specification.
      collection_spec = importlib.util.find_spec(
          collections[args.collection]
      )
      if collection_spec is None:
          logging.error(
              "Failed to load the `{}` collection".format(val)
          )
  
      # Import the module from the module specification.
      collection = importlib.util.module_from_spec(collection_spec)
      collection_spec.loader.exec_module(collection)
  
      module_list = []
      # Iterate over the packages in the indicated collection.
      logging.info(
          "Analysing the `{}` collection".format(args.collection)
      )
  
      try:  # Datasets in dataset folder
          logging.info("Analysing the 'data' package")
          for name, obj in inspect.getmembers(collection.data):
              process_member(name, obj, module_list)
      except AttributeError as e:
          logging.info("  * No datasets found")
  
      try:  # Datasets in dataset folder
          logging.info("Analysing the 'datasets' package")
          for name, obj in inspect.getmembers(collection.datasets):
              process_member(name, obj, module_list)
      except AttributeError as e:
          logging.info("  * No datasets found")
  
      try:  # Modules
          logging.info("Analysing the 'modules' package")
          for name, obj in inspect.getmembers(collection.modules):
              process_member(name, obj, module_list)
      except AttributeError as e:
          logging.info("  * No modules found")
  
      try:  # Losses
          logging.info("Analysing the 'losses' package")
          for name, obj in inspect.getmembers(collection.losses):
              process_member(name, obj, module_list)
      except AttributeError as e:
          logging.info("  * No losses found")
  
      # Add prefix - only for default name.
      filename = (
          args.filename
          if args.filename != "modules.json"
          else args.collection + "_" + args.filename
      )
      # Export to JSON.
      with open(filename, "w", encoding="utf-8") as outfile:
          json.dump(module_list, outfile)
  
      logging.info(
          "Finished analysis of the `{}` collection, results exported to `{}`.".format(
              args.collection, filename
          )
      )
  
file_path: NeMo/external/get_modules.py
imports: import argparse
  import importlib
  import inspect
  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