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 input tensors into latent vectors.
  
  Args:
    input_tensors: Collection of input tensors to encode.
    lengths: Collection of lengths of input tensors.
    control_tensors: Collection of control tensors to encode.
  Returns:
    The encoded `z`, `mu`, and `sigma` values.
  Raises:
     RuntimeError: If called for a non-conditional model.
docstr_tok: ["Encodes","a","collection","of","input","tensors","into","latent","vectors",".","Args",":","input_tensors",":","Collection","of","input","tensors","to","encode",".","lengths",":","Collection","of","lengths","of","input","tensors",".","control_tensors",":","Collection","of","control","tensors","to","encode",".","Returns",":","The","encoded","`","z","`",",","`","mu","`",",","and","`","sigma","`","values",".","Raises",":","RuntimeError",":","If","called","for","a","non-conditional","model","."]
code: def encode_tensors(
      self, input_tensors, lengths, control_tensors=None
  ):
      """Encodes a collection of input tensors into latent vectors.
  
      Args:
        input_tensors: Collection of input tensors to encode.
        lengths: Collection of lengths of input tensors.
        control_tensors: Collection of control tensors to encode.
      Returns:
        The encoded `z`, `mu`, and `sigma` values.
      Raises:
         RuntimeError: If called for a non-conditional model.
      """
      if not self._config.hparams.z_size:
          raise RuntimeError(
              "Cannot encode with a non-conditional model."
          )
  
      n = len(input_tensors)
      input_depth = self._config.data_converter.input_depth
      batch_size = self._config.hparams.batch_size
  
      batch_pad_amt = -n % batch_size
      if batch_pad_amt > 0:
          input_tensors += [np.zeros([0, input_depth])] * batch_pad_amt
      length_array = np.array(lengths, np.int32)
      length_array = np.pad(
          length_array,
          [(0, batch_pad_amt)] + [(0, 0)] * (length_array.ndim - 1),
          "constant",
      )
  
      max_length = max([len(t) for t in input_tensors])
      inputs_array = np.zeros(
          [len(input_tensors), max_length, input_depth]
      )
      for i, t in enumerate(input_tensors):
          inputs_array[i, : len(t)] = t
  
      control_depth = self._config.data_converter.control_depth
      controls_array = np.zeros(
          [len(input_tensors), max_length, control_depth]
      )
      if control_tensors is not None:
          control_tensors += [
              np.zeros([0, control_depth])
          ] * batch_pad_amt
          for i, t in enumerate(control_tensors):
              controls_array[i, : len(t)] = t
  
      outputs = []
      for i in range(len(inputs_array) // batch_size):
          batch_begin = i * batch_size
          batch_end = (i + 1) * batch_size
          feed_dict = {
              self._inputs: inputs_array[batch_begin:batch_end],
              self._controls: controls_array[batch_begin:batch_end],
              self._inputs_length: length_array[batch_begin:batch_end],
          }
          outputs.append(
              self._sess.run(
                  [self._z, self._mu, self._sigma], feed_dict
              )
          )
      assert outputs
      return tuple(np.vstack(v)[:n] for v in zip(*outputs))
  
imports: import copy
  import os
  import re
  import tarfile
  import tempfile
  import numpy
  import tensorflow.compat.v1
label_desc: Use image node_id 4 for calling the TrainedModel obj's underlying member method code with example usage: obj.encode_tensors(input_tensors, lengths, control_tensors) and returns: tuple