code: def main():
      opts = parse_args()
      outputs = opts.out if opts.out else [None] * len(opts.modules)
      if len(outputs) != len(opts.modules):
          raise ValueError(
              "Number inputs and outputs should be the same."
          )
      n_threads = cpu_count()
      errors: int = 0
      if len(opts.modules) > n_threads and opts.out:
          # If writing to files, can process in parallel.
          chunk_size = max([1, int(len(outputs) / n_threads)])
          logger.info("Using %d threads", n_threads)
          with Pool(n_threads) as p:
              for result in p.imap(
                  _py2md_wrapper, zip(opts.modules, outputs), chunk_size
              ):
                  if not result:
                      errors += 1
      else:
          # If writing to stdout, need to process sequentially. Otherwise the output
          # could get intertwined.
          for module, out in zip(opts.modules, outputs):
              result = py2md(module, out)
              if not result:
                  errors += 1
      logger.info("Processed %d modules", len(opts.modules))
      if errors:
          logger.error("Found %d errors", errors)
          sys.exit(1)
  
imports: import argparse
  import logging
  import os
  import re
  import sys
  from collections import OrderedDict
  from dataclasses import dataclass
  from enum import Enum
  from multiprocessing import Pool, cpu_count
  from pathlib import Path
  from typing import List, Optional, Tuple
  import docspec
  from docspec import ApiObject, Class, Data, Function, Indirection, Module
  from docspec_python import format_arglist
  from pydoc_markdown import Processor, PydocMarkdown, Resolver
  from pydoc_markdown.contrib.loaders.python import PythonLoader
  from pydoc_markdown.contrib.renderers.markdown import MarkdownRenderer
label_desc: Use image node_id 5 for calling a global function with example usage: main() without return types