code: def _generate_comparison_rst(
      base_mod,
      cupy_mod,
      base_type,
      klass,
      exclude_mod,
      exclude,
      footnotes=None,
  ):
      base_obj, base_fmt = _import(base_mod, klass)
      base_funcs = _get_functions(base_obj, exclude)
      cp_obj, cp_fmt = _import(cupy_mod, klass)
      cp_funcs = _get_functions(cp_obj)
  
      if exclude_mod:
          exclude_obj, _ = _import(exclude_mod, klass)
          exclude_funcs = _get_functions(exclude_obj)
          base_funcs -= exclude_funcs
          cp_funcs -= exclude_funcs
  
      buf = []
      buf += [
          ".. csv-table::",
          "   :header: {}, CuPy".format(base_type),
          "",
      ]
      for f in sorted(base_funcs):
          footnote_id = None
          if footnotes is not None and f in footnotes:
              footnote_id = _footnotes.setdefault(
                  footnotes[f], f"f{len(_footnotes)}"
              )
  
          base_cell = base_fmt.format(f)
          cp_cell = r"\-"
          if f in cp_funcs:
              cp_cell = cp_fmt.format(f)
              if getattr(base_obj, f) is getattr(cp_obj, f):
                  cp_cell = "{} (*alias of* {})".format(
                      cp_cell, base_cell
                  )
          if footnote_id is not None:
              cp_cell += f" [#{footnote_id}]_"
          line = "   {}, {}".format(base_cell, cp_cell)
          buf.append(line)
  
      buf += [
          "",
          ".. Summary:",
          "   Number of NumPy functions: {}".format(len(base_funcs)),
          "   Number of functions covered by CuPy: {}".format(
              len(cp_funcs & base_funcs)
          ),
          "   CuPy specific functions:",
      ] + ["   - {}".format(f) for f in sorted(cp_funcs - base_funcs)]
      return buf
  
imports: import importlib
  import inspect
  import numpy
label_desc: Use image node_id 3 for calling a global function with example usage: _generate_comparison_rst(base_mod, cupy_mod, base_type, klass, exclude_mod, exclude, footnotes) and returns: buf