class_docstr: An wrapper for the HuggingFace encodec model
  
  Arguments
  ---------
  source : str
      A HuggingFace repository identifier or a path
  save_path : str
      The location where the pretrained model will be saved
  sample_rate : int
      The audio sampling rate
  bandwidth : float
      The encoding bandwidth, in kbps (optional)
      Supported bandwidths:
      1.5, 3.0, 6.0, 12.0, 24.0
  flat_embeddings : bool
      If set to True, embeddings will be flattened into
      (Batch x Length x (Heads * Embedding))
  freeze : bool
      whether the model will be frozen (e.g. not trainable if used
      as part of training another model)
  renorm_embeddings : bool
      whether embeddings should be renormalized. In the original
      model.
  
  Example
  -------
  >>> model_hub = "facebook/encodec_24khz"
  >>> save_path = "savedir"
  >>> model = Encodec(model_hub, save_path)
  >>> audio = torch.randn(4, 1000)
  >>> length = torch.tensor([1.0, .5, .75, 1.0])
  >>> tokens, emb = model.encode(audio, length)
  >>> tokens.shape
  torch.Size([4, 4, 2])
  >>> emb.shape
  torch.Size([4, 4, 2, 128])
  >>> rec = model.decode(tokens, length)
  >>> rec.shape
  torch.Size([4, 1, 1280])
  >>> rec_emb = model.decode_emb(emb, length)
  >>> rec_emb.shape
  torch.Size([4, 1, 1280])
  >>> rec_tokens = model.tokens(emb, length)
  >>> rec_tokens.shape
  torch.Size([4, 4, 2])
  >>> model = Encodec(model_hub, save_path, flat_embeddings=True)
  >>> _, emb = model.encode(audio, length)
  >>> emb.shape
  torch.Size([4, 4, 256])
class_docstr_tok: ["An","wrapper","for","the","HuggingFace","encodec","model","Arguments","--","--","--","--","-","source",":","str","A","HuggingFace","repository","identifier","or","a","path","save_path",":","str","The","location","where","the","pretrained","model","will","be","saved","sample_rate",":","int","The","audio","sampling","rate","bandwidth",":","float","The","encoding","bandwidth",",","in","kbps","(","optional",")","Supported","bandwidths",":","1.5",",","3.0",",","6.0",",","12.0",",","24.0","flat_embeddings",":","bool","If","set","to","True",",","embeddings","will","be","flattened","into","(","Batch","x","Length","x","(","Heads","*","Embedding",")",")","freeze",":","bool","whether","the","model","will","be","frozen","(","e.g",".","not","trainable","if","used","as","part","of","training","another","model",")","renorm_embeddings",":","bool","whether","embeddings","should","be","renormalized",".","In","the","original","model",".","Example","--","--","--","-",">",">",">","model_hub","=","``","facebook\/encodec_24khz","''",">",">",">","save_path","=","``","savedir","''",">",">",">","model","=","Encodec","(","model_hub",",","save_path",")",">",">",">","audio","=","torch.randn","(","4",",","1000",")",">",">",">","length","=","torch.tensor","(","[","1.0",",",".5",",",".75",",","1.0","]",")",">",">",">","tokens",",","emb","=","model.encode","(","audio",",","length",")",">",">",">","tokens.shape","torch.Size","(","[","4",",","4",",","2","]",")",">",">",">","emb.shape","torch.Size","(","[","4",",","4",",","2",",","128","]",")",">",">",">","rec","=","model.decode","(","tokens",",","length",")",">",">",">","rec.shape","torch.Size","(","[","4",",","1",",","1280","]",")",">",">",">","rec_emb","=","model.decode_emb","(","emb",",","length",")",">",">",">","rec_emb.shape","torch.Size","(","[","4",",","1",",","1280","]",")",">",">",">","rec_tokens","=","model.tokens","(","emb",",","length",")",">",">",">","rec_tokens.shape","torch.Size","(","[","4",",","4",",","2","]",")",">",">",">","model","=","Encodec","(","model_hub",",","save_path",",","flat_embeddings=True",")",">",">",">","_",",","emb","=","model.encode","(","audio",",","length",")",">",">",">","emb.shape","torch.Size","(","[","4",",","4",",","256","]",")"]
docstr: Encodes the input audio as tokens and embeddings
  
  Arguments
  ---------
  inputs : torch.Tensor
      A (Batch x Samples) or (Batch x Channel x Samples)
      tensor of audio
  length : torch.Tensor
      A tensor of relative lengths
  
  Returns
  -------
  tokens : torch.Tensor
      A (Batch x Tokens x Heads) tensor of audio tokens
  emb : torch.Tensor
      Raw vector embeddings from the model's
      quantizers
docstr_tok: ["Encodes","the","input","audio","as","tokens","and","embeddings","Arguments","--","--","--","--","-","inputs",":","torch.Tensor","A","(","Batch","x","Samples",")","or","(","Batch","x","Channel","x","Samples",")","tensor","of","audio","length",":","torch.Tensor","A","tensor","of","relative","lengths","Returns","--","--","--","-","tokens",":","torch.Tensor","A","(","Batch","x","Tokens","x","Heads",")","tensor","of","audio","tokens","emb",":","torch.Tensor","Raw","vector","embeddings","from","the","model's","quantizers"]
code: def encode(self, inputs, length):
      """Encodes the input audio as tokens and embeddings
  
      Arguments
      ---------
      inputs : torch.Tensor
          A (Batch x Samples) or (Batch x Channel x Samples)
          tensor of audio
      length : torch.Tensor
          A tensor of relative lengths
  
      Returns
      -------
      tokens : torch.Tensor
          A (Batch x Tokens x Heads) tensor of audio tokens
      emb : torch.Tensor
          Raw vector embeddings from the model's
          quantizers
      """
      with torch.set_grad_enabled(not self.freeze):
          tokens = self._encode_tokens(inputs, length)
          emb = self.embeddings(tokens)
          return tokens, emb
  
file_path: speechbrain/speechbrain/lobes/models/huggingface_transformers/encodec.py
imports: import torch
  import logging
  from torch.nn import functional
  from speechbrain.dataio.dataio import length_to_mask, clean_padding_
  from speechbrain.lobes.models.huggingface_transformers.huggingface import HFTransformersInterface
label_desc: Use image node_id 6 for calling the Encodec obj's underlying member method code with example usage: obj.encode(inputs, length) and returns: tokens,  emb