class_docstr: An interface to a trained model for encoding, decoding, and sampling.
  
  Attributes:
    config: The Config to build the model graph with.
    batch_size: The batch size to build the model graph with.
    checkpoint_dir_or_path: The directory containing checkpoints for the model,
      the most recent of which will be loaded, or a direct path to a specific
      checkpoint.
    var_name_substitutions: Optional list of string pairs containing regex
      patterns and substitution values for renaming model variables to match
      those in the checkpoint. Useful for backwards compatibility.
    session_target: Optional execution engine to connect to. Defaults to
      in-process.
    sample_kwargs: Additional, non-tensor keyword arguments to pass to sample
      call.
class_docstr_tok: ["An","interface","to","a","trained","model","for","encoding",",","decoding",",","and","sampling",".","Attributes",":","config",":","The","Config","to","build","the","model","graph","with",".","batch_size",":","The","batch","size","to","build","the","model","graph","with",".","checkpoint_dir_or_path",":","The","directory","containing","checkpoints","for","the","model",",","the","most","recent","of","which","will","be","loaded",",","or","a","direct","path","to","a","specific","checkpoint",".","var_name_substitutions",":","Optional","list","of","string","pairs","containing","regex","patterns","and","substitution","values","for","renaming","model","variables","to","match","those","in","the","checkpoint",".","Useful","for","backwards","compatibility",".","session_target",":","Optional","execution","engine","to","connect","to",".","Defaults","to","in-process",".","sample_kwargs",":","Additional",",","non-tensor","keyword","arguments","to","pass","to","sample","call","."]
docstr: Encodes a collection of NoteSequences into latent vectors.
  
  Args:
    note_sequences: A collection of NoteSequence objects to encode.
    assert_same_length: Whether to raise an AssertionError if all of the
      extracted sequences are not the same length.
  Returns:
    The encoded `z`, `mu`, and `sigma` values.
  Raises:
    RuntimeError: If called for a non-conditional model.
    NoExtractedExamplesError: If no examples were extracted.
    MultipleExtractedExamplesError: If multiple examples were extracted.
    AssertionError: If `assert_same_length` is True and any extracted
      sequences differ in length.
docstr_tok: ["Encodes","a","collection","of","NoteSequences","into","latent","vectors",".","Args",":","note_sequences",":","A","collection","of","NoteSequence","objects","to","encode",".","assert_same_length",":","Whether","to","raise","an","AssertionError","if","all","of","the","extracted","sequences","are","not","the","same","length",".","Returns",":","The","encoded","`","z","`",",","`","mu","`",",","and","`","sigma","`","values",".","Raises",":","RuntimeError",":","If","called","for","a","non-conditional","model",".","NoExtractedExamplesError",":","If","no","examples","were","extracted",".","MultipleExtractedExamplesError",":","If","multiple","examples","were","extracted",".","AssertionError",":","If","`","assert_same_length","`","is","True","and","any","extracted","sequences","differ","in","length","."]
code: def encode(self, note_sequences, assert_same_length=False):
      """Encodes a collection of NoteSequences into latent vectors.
  
      Args:
        note_sequences: A collection of NoteSequence objects to encode.
        assert_same_length: Whether to raise an AssertionError if all of the
          extracted sequences are not the same length.
      Returns:
        The encoded `z`, `mu`, and `sigma` values.
      Raises:
        RuntimeError: If called for a non-conditional model.
        NoExtractedExamplesError: If no examples were extracted.
        MultipleExtractedExamplesError: If multiple examples were extracted.
        AssertionError: If `assert_same_length` is True and any extracted
          sequences differ in length.
      """
      if not self._config.hparams.z_size:
          raise RuntimeError(
              "Cannot encode with a non-conditional model."
          )
  
      inputs = []
      controls = []
      lengths = []
      for note_sequence in note_sequences:
          extracted_tensors = self._config.data_converter.to_tensors(
              note_sequence
          )
          if not extracted_tensors.inputs:
              raise NoExtractedExamplesError(
                  "No examples extracted from NoteSequence: %s"
                  % note_sequence
              )
          if len(extracted_tensors.inputs) > 1:
              raise MultipleExtractedExamplesError(
                  "Multiple (%d) examples extracted from NoteSequence: %s"
                  % (len(extracted_tensors.inputs), note_sequence)
              )
          inputs.append(extracted_tensors.inputs[0])
          controls.append(extracted_tensors.controls[0])
          lengths.append(extracted_tensors.lengths[0])
          if assert_same_length and len(inputs[0]) != len(inputs[-1]):
              raise AssertionError(
                  "Sequences 0 and %d have different lengths: %d vs %d"
                  % (len(inputs) - 1, len(inputs[0]), len(inputs[-1]))
              )
      return self.encode_tensors(inputs, lengths, controls)
  
imports: import copy
  import os
  import re
  import tarfile
  import tempfile
  import numpy
  import tensorflow.compat.v1
label_desc: Use image node_id 3 for calling the TrainedModel obj's underlying member method code with example usage: obj.encode(note_sequences, assert_same_length) and returns: self