code: def add_parser(parser):
      """
      Add an onset evaluation sub-parser to an existing parser.
  
      Parameters
      ----------
      parser : argparse parser instance
          Existing argparse parser object.
  
      Returns
      -------
      sub_parser : argparse sub-parser instance
          Onset evaluation sub-parser.
      parser_group : argparse argument group
          Onset evaluation argument group.
  
      """
      import argparse
  
      # add beat evaluation sub-parser to the existing parser
      p = parser.add_parser(
          "onsets",
          help="onset evaluation",
          formatter_class=argparse.RawDescriptionHelpFormatter,
          description="""
      This program evaluates pairs of files containing the onset annotations and
      detections. Suffixes can be given to filter them from the list of files.
  
      Each line represents an onset and must have the following format:
      `onset_time`.
  
      Lines starting with # are treated as comments and are ignored.
  
      """,
      )
      # set defaults
      p.set_defaults(
          eval=OnsetEvaluation,
          sum_eval=OnsetSumEvaluation,
          mean_eval=OnsetMeanEvaluation,
          load_fn=load_onsets,
      )
      # file I/O
      evaluation_io(p, ann_suffix=".onsets", det_suffix=".onsets.txt")
      # evaluation parameters
      g = p.add_argument_group("onset evaluation arguments")
      g.add_argument(
          "-w",
          dest="window",
          action="store",
          type=float,
          default=WINDOW,
          help="evaluation window (+/- the given size) "
          "[seconds, default=%(default).3f]",
      )
      g.add_argument(
          "-c",
          dest="combine",
          action="store",
          type=float,
          default=COMBINE,
          help="combine annotation events within this range "
          "[seconds, default=%(default).3f]",
      )
      g.add_argument(
          "--delay",
          action="store",
          type=float,
          default=0.0,
          help="add given delay to all detections [seconds]",
      )
      # return the sub-parser and evaluation argument group
      return p, g
  
imports: from __future__ import absolute_import, division, print_function
  import numpy
  from .None import Evaluation, MeanEvaluation, SumEvaluation, evaluation_io
  from ..io import load_onsets
  from ..utils import combine_events
label_desc: Use image node_id 2 for calling a global function with example usage: add_parser(parser) and returns: p,  g