class_docstr: Introduced in SoundStream: An end2end neural audio codec
  https://arxiv.org/abs/2107.03312
  
  
  Example
  -------
  Using a pretrained RVQ unit.
  
  >>> dac = DAC(load_pretrained=True, model_type="44KHz", model_bitrate="8kbps", tag="latest")
  >>> quantizer = dac.quantizer
  >>> continuous_embeddings = torch.randn(1, 1024, 100) # Example shape: [Batch, Channels, Time]
  >>> discrete_embeddings, codes, _, _, _ = quantizer(continuous_embeddings)
class_docstr_tok: ["Introduced","in","SoundStream",":","An","end2end","neural","audio","codec","https",":","\/\/arxiv.org\/abs\/2107.03312","Example","--","--","--","-","Using","a","pretrained","RVQ","unit",".",">",">",">","dac","=","DAC","(","load_pretrained=True",",","model_type=","''","44KHz","''",",","model_bitrate=","''","8kbps","''",",","tag=","''","latest","''",")",">",">",">","quantizer","=","dac.quantizer",">",">",">","continuous_embeddings","=","torch.randn","(","1",",","1024",",","100",")","#","Example","shape",":","[","Batch",",","Channels",",","Time","]",">",">",">","discrete_embeddings",",","codes",",","_",",","_",",","_","=","quantizer","(","continuous_embeddings",")"]
docstr: Given the unquantized latents, reconstruct the
  continuous representation after quantization.
  
  Parameters
  ----------
  latents : Tensor[B x N x T]
      Continuous representation of input after projection
  
  Returns
  -------
  Tensor[B x D x T]
      Quantized representation of full-projected space
  Tensor[B x D x T]
      Quantized representation of latent space
docstr_tok: ["Given","the","unquantized","latents",",","reconstruct","the","continuous","representation","after","quantization",".","Parameters","--","--","--","--","--","latents",":","Tensor","[","B","x","N","x","T","]","Continuous","representation","of","input","after","projection","Returns","--","--","--","-","Tensor","[","B","x","D","x","T","]","Quantized","representation","of","full-projected","space","Tensor","[","B","x","D","x","T","]","Quantized","representation","of","latent","space"]
code: def from_latents(self, latents: torch.Tensor):
      """Given the unquantized latents, reconstruct the
      continuous representation after quantization.
  
      Parameters
      ----------
      latents : Tensor[B x N x T]
          Continuous representation of input after projection
  
      Returns
      -------
      Tensor[B x D x T]
          Quantized representation of full-projected space
      Tensor[B x D x T]
          Quantized representation of latent space
      """
      z_q = 0
      z_p = []
      codes = []
      dims = np.cumsum([0] + [q.codebook_dim for q in self.quantizers])
  
      n_codebooks = np.where(dims <= latents.shape[1])[0].max(
          axis=0, keepdims=True
      )[0]
      for i in range(n_codebooks):
          j, k = dims[i], dims[i + 1]
          z_p_i, codes_i = self.quantizers[i].decode_latents(
              latents[:, j:k, :]
          )
          z_p.append(z_p_i)
          codes.append(codes_i)
  
          z_q_i = self.quantizers[i].out_proj(z_p_i)
          z_q = z_q + z_q_i
  
      return z_q, torch.cat(z_p, dim=1), torch.stack(codes, dim=1)
  
imports: import math
  from pathlib import Path
  from typing import List, Union
  import logging
  import numpy
  import torch
  import torch.nn
  import torch.nn.functional
  from torch.nn.utils.parametrizations import weight_norm
label_desc: Use image node_id 4 for calling the ResidualVectorQuantize obj's underlying member method code with example usage: obj.from_latents(latents) and returns: z_q,  torch,  torch