code: def remove_short(is_on_vec, min_samples=20, glue_back=False):
      """Removes short notes and optionally reattaches them to the previous note."""
      has_been_on = 0
      prev_note_end = 0
      for i, is_on in enumerate(
          np.nditer(is_on_vec, flags=("refs_ok",))
      ):
          if is_on:
              has_been_on += 1
          else:
              if has_been_on < min_samples:
                  # set this "on" stretch to off
                  if glue_back:
                      is_on_vec[prev_note_end:i] = True
                  else:
                      is_on_vec[i - has_been_on : i] = False
              has_been_on = 0
              prev_note_end = i
      return is_on_vec
  
file_path: ddsp/ddsp/training/heuristics.py
imports: import ddsp
  import gin
  import note_seq
  import numpy
  import tensorflow.compat.v2
label_desc: Use image node_id 9 for calling a global function with example usage: remove_short(is_on_vec, min_samples, glue_back) and returns: is_on_vec