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: Generates random samples from the model.
  
  Args:
    n: The number of samples to return. A full batch will be returned if not
      specified.
    length: The maximum length of a sample in decoder iterations. Required
      if end tokens are not being used.
    temperature: The softmax temperature to use (if applicable).
    same_z: Whether to use the same latent vector for all samples in the
      batch (if applicable).
    c_input: A sequence of control inputs to use for all samples (if
      applicable).
  Returns:
    A list of samples as NoteSequence objects.
  Raises:
    ValueError: If `length` is not specified and an end token is not being
      used.
docstr_tok: ["Generates","random","samples","from","the","model",".","Args",":","n",":","The","number","of","samples","to","return",".","A","full","batch","will","be","returned","if","not","specified",".","length",":","The","maximum","length","of","a","sample","in","decoder","iterations",".","Required","if","end","tokens","are","not","being","used",".","temperature",":","The","softmax","temperature","to","use","(","if","applicable",")",".","same_z",":","Whether","to","use","the","same","latent","vector","for","all","samples","in","the","batch","(","if","applicable",")",".","c_input",":","A","sequence","of","control","inputs","to","use","for","all","samples","(","if","applicable",")",".","Returns",":","A","list","of","samples","as","NoteSequence","objects",".","Raises",":","ValueError",":","If","`","length","`","is","not","specified","and","an","end","token","is","not","being","used","."]
code: def sample(
      self,
      n=None,
      length=None,
      temperature=1.0,
      same_z=False,
      c_input=None,
  ):
      """Generates random samples from the model.
  
      Args:
        n: The number of samples to return. A full batch will be returned if not
          specified.
        length: The maximum length of a sample in decoder iterations. Required
          if end tokens are not being used.
        temperature: The softmax temperature to use (if applicable).
        same_z: Whether to use the same latent vector for all samples in the
          batch (if applicable).
        c_input: A sequence of control inputs to use for all samples (if
          applicable).
      Returns:
        A list of samples as NoteSequence objects.
      Raises:
        ValueError: If `length` is not specified and an end token is not being
          used.
      """
      batch_size = self._config.hparams.batch_size
      n = n or batch_size
      z_size = self._config.hparams.z_size
  
      if not length and self._config.data_converter.end_token is None:
          raise ValueError(
              "A length must be specified when the end token is not used."
          )
      length = length or tf.int32.max
  
      feed_dict = {
          self._temperature: temperature,
          self._max_length: length,
      }
  
      if self._z_input is not None and same_z:
          z = np.random.randn(z_size).astype(np.float32)
          z = np.tile(z, (batch_size, 1))
          feed_dict[self._z_input] = z
  
      if self._c_input is not None:
          feed_dict[self._c_input] = c_input
  
      outputs = []
      for _ in range(int(np.ceil(n / batch_size))):
          if self._z_input is not None and not same_z:
              feed_dict[self._z_input] = np.random.randn(
                  batch_size, z_size
              ).astype(np.float32)
          outputs.append(self._sess.run(self._outputs, feed_dict))
      samples = np.vstack(outputs)[:n]
      if self._c_input is not None:
          return self._config.data_converter.from_tensors(
              samples,
              np.tile(np.expand_dims(c_input, 0), [batch_size, 1, 1]),
          )
      else:
          return self._config.data_converter.from_tensors(samples)
  
imports: import copy
  import os
  import re
  import tarfile
  import tempfile
  import numpy
  import tensorflow.compat.v1
label_desc: Use image node_id 2 for calling the TrainedModel obj's underlying member method code with example usage: obj.sample(n, length, temperature, same_z, c_input) and returns: self, self