code: def preprocess_data(
      input_example,
      preprocess_example_fn,
      input_tensors_to_example_fn,
      hparams,
      process_for_training,
  ):
      """Preprocess example using data.preprocess_data."""
      with tf.Graph().as_default():
          example_proto = tf.constant(input_example.SerializeToString())
  
          input_tensors = preprocess_example_fn(
              example_proto=example_proto,
              hparams=hparams,
              is_training=process_for_training,
          )
  
          with tf.Session() as sess:
              preprocessed = sess.run(input_tensors)
  
      example = input_tensors_to_example_fn(preprocessed, hparams)
      Metrics.counter("preprocess_data", "preprocess_example").inc()
      return example
  
file_path: magenta/magenta/models/onsets_frames_transcription/create_dataset.py
imports: import hashlib
  import os
  import apache_beam
  from apache_beam.metrics import Metrics
  from magenta.models.onsets_frames_transcription import audio_label_data_utils
  from magenta.models.onsets_frames_transcription import create_dataset_lib
  from magenta.models.onsets_frames_transcription import data
  from note_seq import audio_io
  from note_seq.protobuf import music_pb2
  import tensorflow.compat.v1
label_desc: Use image node_id 3 for calling a global function with example usage: preprocess_data(input_example, preprocess_example_fn, input_tensors_to_example_fn, hparams, process_for_training) and returns: example