class_docstr: Discrete Autoencoder Codec (DAC) for audio data encoding and decoding.
  
  This class implements an autoencoder architecture with quantization for efficient audio processing.
  It includes an encoder, quantizer, and decoder for transforming audio data into a compressed latent representation and reconstructing it back into audio.
  This implementation supports both initializing a new model and loading a pretrained model.
  
  Parameters
  ----------
  encoder_dim : int
      Dimensionality of the encoder.
  encoder_rates : List[int]
      Downsampling rates for each encoder layer.
  latent_dim : int, optional
      Dimensionality of the latent space, automatically calculated if None.
  decoder_dim : int
      Dimensionality of the decoder.
  decoder_rates : List[int]
      Upsampling rates for each decoder layer.
  n_codebooks : int
      Number of codebooks for vector quantization.
  codebook_size : int
      Size of each codebook.
  codebook_dim : Union[int, list]
      Dimensionality of each codebook entry.
  quantizer_dropout : bool
      Whether to use dropout in the quantizer.
  sample_rate : int
      Sample rate of the audio data.
  model_type : str
      Type of the model to load (if pretrained).
  model_bitrate : str
      Bitrate of the model to load (if pretrained).
  tag : str
      Specific tag of the model to load (if pretrained).
  load_path : str, optional
      Path to load the pretrained model from, automatically downloaded if None.
  strict : bool
      Whether to strictly enforce the state dictionary match.
  load_pretrained : bool
      Whether to load a pretrained model.
  
  Example
  -------
  Creating a new DAC instance:
  
  >>> dac = DAC()
  >>> audio_data = torch.randn(1, 1, 16000) # Example shape: [Batch, Channels, Time]
  >>> tokens, embeddings = dac(audio_data)
  
  
  Loading a pretrained DAC instance:
  
  >>> dac = DAC(load_pretrained=True, model_type="44KHz", model_bitrate="8kbps", tag="latest")
  >>> audio_data = torch.randn(1, 1, 16000) # Example shape: [Batch, Channels, Time]
  >>> tokens, embeddings = dac(audio_data)
  
  The tokens and the discrete embeddings obtained above or from other sources can be decoded:
  
  >>> dac = DAC(load_pretrained=True, model_type="44KHz", model_bitrate="8kbps", tag="latest")
  >>> audio_data = torch.randn(1, 1, 16000) # Example shape: [Batch, Channels, Time]
  >>> tokens, embeddings = dac(audio_data)
  >>> decoded_audio = dac.decode(embeddings)
class_docstr_tok: ["Discrete","Autoencoder","Codec","(","DAC",")","for","audio","data","encoding","and","decoding",".","This","class","implements","an","autoencoder","architecture","with","quantization","for","efficient","audio","processing",".","It","includes","an","encoder",",","quantizer",",","and","decoder","for","transforming","audio","data","into","a","compressed","latent","representation","and","reconstructing","it","back","into","audio",".","This","implementation","supports","both","initializing","a","new","model","and","loading","a","pretrained","model",".","Parameters","--","--","--","--","--","encoder_dim",":","int","Dimensionality","of","the","encoder",".","encoder_rates",":","List","[","int","]","Downsampling","rates","for","each","encoder","layer",".","latent_dim",":","int",",","optional","Dimensionality","of","the","latent","space",",","automatically","calculated","if","None",".","decoder_dim",":","int","Dimensionality","of","the","decoder",".","decoder_rates",":","List","[","int","]","Upsampling","rates","for","each","decoder","layer",".","n_codebooks",":","int","Number","of","codebooks","for","vector","quantization",".","codebook_size",":","int","Size","of","each","codebook",".","codebook_dim",":","Union","[","int",",","list","]","Dimensionality","of","each","codebook","entry",".","quantizer_dropout",":","bool","Whether","to","use","dropout","in","the","quantizer",".","sample_rate",":","int","Sample","rate","of","the","audio","data",".","model_type",":","str","Type","of","the","model","to","load","(","if","pretrained",")",".","model_bitrate",":","str","Bitrate","of","the","model","to","load","(","if","pretrained",")",".","tag",":","str","Specific","tag","of","the","model","to","load","(","if","pretrained",")",".","load_path",":","str",",","optional","Path","to","load","the","pretrained","model","from",",","automatically","downloaded","if","None",".","strict",":","bool","Whether","to","strictly","enforce","the","state","dictionary","match",".","load_pretrained",":","bool","Whether","to","load","a","pretrained","model",".","Example","--","--","--","-","Creating","a","new","DAC","instance",":",">",">",">","dac","=","DAC","(",")",">",">",">","audio_data","=","torch.randn","(","1",",","1",",","16000",")","#","Example","shape",":","[","Batch",",","Channels",",","Time","]",">",">",">","tokens",",","embeddings","=","dac","(","audio_data",")","Loading","a","pretrained","DAC","instance",":",">",">",">","dac","=","DAC","(","load_pretrained=True",",","model_type=","''","44KHz","''",",","model_bitrate=","''","8kbps","''",",","tag=","''","latest","''",")",">",">",">","audio_data","=","torch.randn","(","1",",","1",",","16000",")","#","Example","shape",":","[","Batch",",","Channels",",","Time","]",">",">",">","tokens",",","embeddings","=","dac","(","audio_data",")","The","tokens","and","the","discrete","embeddings","obtained","above","or","from","other","sources","can","be","decoded",":",">",">",">","dac","=","DAC","(","load_pretrained=True",",","model_type=","''","44KHz","''",",","model_bitrate=","''","8kbps","''",",","tag=","''","latest","''",")",">",">",">","audio_data","=","torch.randn","(","1",",","1",",","16000",")","#","Example","shape",":","[","Batch",",","Channels",",","Time","]",">",">",">","tokens",",","embeddings","=","dac","(","audio_data",")",">",">",">","decoded_audio","=","dac.decode","(","embeddings",")"]
docstr: Decode given latent codes and return audio data
  
  Parameters
  ----------
  z : Tensor[B x D x T]
      Quantized continuous representation of input
  length : int, optional
      Number of samples in output audio, by default None
  
  Returns
  -------
  torch.Tensor: shape B x 1 x length
      Decoded audio data.
docstr_tok: ["Decode","given","latent","codes","and","return","audio","data","Parameters","--","--","--","--","--","z",":","Tensor","[","B","x","D","x","T","]","Quantized","continuous","representation","of","input","length",":","int",",","optional","Number","of","samples","in","output","audio",",","by","default","None","Returns","--","--","--","-","torch.Tensor",":","shape","B","x","1","x","length","Decoded","audio","data","."]
code: def decode(self, z: torch.Tensor):
      """Decode given latent codes and return audio data
  
      Parameters
      ----------
      z : Tensor[B x D x T]
          Quantized continuous representation of input
      length : int, optional
          Number of samples in output audio, by default None
  
      Returns
      -------
      torch.Tensor: shape B x 1 x length
          Decoded audio data.
      """
      return self.decoder(z)
  
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 3 for calling the DAC obj's underlying member method code with example usage: obj.decode(z) and returns: self