class_docstr: Music Variational Autoencoder.
class_docstr_tok: ["Music","Variational","Autoencoder","."]
docstr: Sample with an optional conditional embedding `z`.
docstr_tok: ["Sample","with","an","optional","conditional","embedding","`","z","`","."]
code: def sample(self, n, max_length=None, z=None, c_input=None, **kwargs):
      """Sample with an optional conditional embedding `z`."""
      if z is not None and int(z.shape[0]) != n:
          raise ValueError(
              "`z` must have a first dimension that equals `n` when given. "
              "Got: %d vs %d" % (z.shape[0], n)
          )
  
      if self.hparams.z_size and z is None:
          tf.logging.warning(
              "Sampling from conditional model without `z`. Using random `z`."
          )
          normal_shape = [n, self.hparams.z_size]
          normal_dist = tfp.distributions.Normal(
              loc=tf.zeros(normal_shape), scale=tf.ones(normal_shape)
          )
          z = normal_dist.sample()
  
      return self.decoder.sample(n, max_length, z, c_input, **kwargs)
  
imports: import abc
  from magenta.contrib import training
  import tensorflow.compat.v1
  import tensorflow_probability
  import tf_slim
label_desc: Use image node_id 10 for calling the MusicVAE obj's underlying member method code with example usage: obj.sample(n, max_length, z, c_input) and returns: self