class_docstr: Music Variational Autoencoder.
class_docstr_tok: ["Music","Variational","Autoencoder","."]
docstr: Encodes input sequences into a MultivariateNormalDiag distribution.
  
  Args:
    sequence: A Tensor with shape `[num_sequences, max_length, input_depth]`
        containing the sequences to encode.
    sequence_length: The length of each sequence in the `sequence` Tensor.
    control_sequence: (Optional) A Tensor with shape
        `[num_sequences, max_length, control_depth]` containing control
        sequences on which to condition. These will be concatenated depthwise
        to the input sequences.
  
  Returns:
    A tfp.distributions.MultivariateNormalDiag representing the posterior
    distribution for each sequence.
docstr_tok: ["Encodes","input","sequences","into","a","MultivariateNormalDiag","distribution",".","Args",":","sequence",":","A","Tensor","with","shape","`","[","num_sequences",",","max_length",",","input_depth","]","`","containing","the","sequences","to","encode",".","sequence_length",":","The","length","of","each","sequence","in","the","`","sequence","`","Tensor",".","control_sequence",":","(","Optional",")","A","Tensor","with","shape","`","[","num_sequences",",","max_length",",","control_depth","]","`","containing","control","sequences","on","which","to","condition",".","These","will","be","concatenated","depthwise","to","the","input","sequences",".","Returns",":","A","tfp.distributions.MultivariateNormalDiag","representing","the","posterior","distribution","for","each","sequence","."]
code: def encode(self, sequence, sequence_length, control_sequence=None):
      """Encodes input sequences into a MultivariateNormalDiag distribution.
  
      Args:
        sequence: A Tensor with shape `[num_sequences, max_length, input_depth]`
            containing the sequences to encode.
        sequence_length: The length of each sequence in the `sequence` Tensor.
        control_sequence: (Optional) A Tensor with shape
            `[num_sequences, max_length, control_depth]` containing control
            sequences on which to condition. These will be concatenated depthwise
            to the input sequences.
  
      Returns:
        A tfp.distributions.MultivariateNormalDiag representing the posterior
        distribution for each sequence.
      """
      hparams = self.hparams
      z_size = hparams.z_size
  
      sequence = tf.to_float(sequence)
      if control_sequence is not None:
          control_sequence = tf.to_float(control_sequence)
          sequence = tf.concat([sequence, control_sequence], axis=-1)
      encoder_output = self.encoder.encode(sequence, sequence_length)
  
      mu = tf.layers.dense(
          encoder_output,
          z_size,
          name="encoder/mu",
          kernel_initializer=tf.random_normal_initializer(stddev=0.001),
      )
      sigma = tf.layers.dense(
          encoder_output,
          z_size,
          activation=tf.nn.softplus,
          name="encoder/sigma",
          kernel_initializer=tf.random_normal_initializer(stddev=0.001),
      )
  
      return ds.MultivariateNormalDiag(loc=mu, scale_diag=sigma)
  
imports: import abc
  from magenta.contrib import training
  import tensorflow.compat.v1
  import tensorflow_probability
  import tf_slim
label_desc: Use image node_id 6 for calling the MusicVAE obj's underlying member method code with example usage: obj.encode(sequence, sequence_length, control_sequence) and returns: ds