code: def adjust(det_chords, ann_chords):
      """
      Adjust the length of detected chord segments to the annotation
      length.
  
      Discard detected chords that start after the annotation ended,
      and shorten the last detection to fit the last annotation;
      discared detected chords that end before the annotation begins,
      and shorten the first detection to match the first annotation.
  
      Parameters
      ----------
      det_chords : numpy structured array
          Detected chord segments.
      ann_chords : numpy structured array
          Annotated chord segments.
  
      Returns
      -------
      det_chords : numpy structured array
          Adjusted detected chord segments.
  
      """
      det_start = det_chords[0]["start"]
      ann_start = ann_chords[0]["start"]
      if det_start > ann_start:
          filler = np.array(
              (ann_start, det_start, chord("N")), dtype=CHORD_ANN_DTYPE
          )
          det_chords = np.hstack([filler, det_chords])
      elif det_start < ann_start:
          det_chords = det_chords[det_chords["end"] > ann_start]
          det_chords[0]["start"] = ann_start
  
      det_end = det_chords[-1]["end"]
      ann_end = ann_chords[-1]["end"]
      if det_end < ann_end:
          filler = np.array(
              (det_end, ann_end, chord("N")), dtype=CHORD_ANN_DTYPE
          )
          det_chords = np.hstack([det_chords, filler])
      elif det_end > ann_end:
          det_chords = det_chords[det_chords["start"] < ann_end]
          det_chords[-1]["end"] = ann_chords[-1]["end"]
  
      return det_chords
  
imports: import numpy
  from .None import evaluation_io, EvaluationMixin
  from ..io import load_chords
label_desc: Use image node_id 17 for calling a global function with example usage: adjust(det_chords, ann_chords) and returns: det_chords