code: def generate_audio_sample(sess, net, audio, encoding):
      """Generate a single sample of audio from an encoding.
  
      Args:
        sess: tf.Session to use.
        net: Loaded wavenet network (dictionary of endpoint tensors).
        audio: Previously generated audio [batch_size, 1].
        encoding: Encoding at current time index [batch_size, dim].
  
      Returns:
        audio_gen: Generated audio [batch_size, 1]
      """
      probability_mass_function = sess.run(
          [net["predictions"], net["push_ops"]],
          feed_dict={net["X"]: audio, net["encoding"]: encoding},
      )[0]
      sample_bin = sample_categorical(probability_mass_function)
      audio_gen = utils.inv_mu_law_numpy(sample_bin - 128)
      return audio_gen
  
file_path: magenta/magenta/models/nsynth/wavenet/fastgen.py
imports: from magenta.models.nsynth import utils
  from magenta.models.nsynth.wavenet.h512_bo16 import Config
  from magenta.models.nsynth.wavenet.h512_bo16 import FastGenerationConfig
  import numpy
  from scipy.io import wavfile
  import tensorflow.compat.v1
label_desc: Use image node_id 8 for calling a global function with example usage: generate_audio_sample(sess, net, audio, encoding) and returns: audio_gen