code: def truncate_note_sequence_op(
      sequence_tensor, truncated_length_frames, hparams
  ):
      """Truncates a NoteSequence to the given length."""
  
      def truncate(sequence_tensor, num_frames):
          sequence = music_pb2.NoteSequence.FromString(sequence_tensor)
          num_secs = num_frames / hparams_frames_per_second(hparams)
          return truncate_note_sequence(
              sequence, num_secs
          ).SerializeToString()
  
      res = tf.py_func(
          truncate,
          [sequence_tensor, truncated_length_frames],
          tf.string,
      )
      res.set_shape(())
      return res
  
imports: import collections
  import functools
  import io
  import re
  import wave
  import zlib
  import librosa
  from magenta.models.onsets_frames_transcription import audio_transform
  from magenta.models.onsets_frames_transcription import constants
  from magenta.models.onsets_frames_transcription import drum_mappings
  from magenta.models.onsets_frames_transcription import melspec_input
  from note_seq import audio_io
  from note_seq import sequences_lib
  from note_seq.protobuf import music_pb2
  import numpy
  import tensorflow.compat.v1
label_desc: Use image node_id 17 for calling a global function with example usage: truncate_note_sequence_op(sequence_tensor, truncated_length_frames, hparams) and returns: res, truncate_note_sequence