class_docstr: Length-extrapolatable positional embedding (xPos) from [Sun et al 2022](https://arxiv.org/abs/2212.10554v1).
  This applies an exponential decay to the RoPE rotation matrix.
  
  Args:
      dim (int): Embedding dimension.
      smoothing (float): Smoothing factor applied to the decay rates.
      base_scale (int): Base decay rate, given in terms of scaling time.
      device (torch.device, optional): Device on which to initialize the module.
      dtype (torch.dtype): dtype to use to generate the embedding.
class_docstr_tok: ["Length-extrapolatable","positional","embedding","(","xPos",")","from","[","Sun","et","al","2022","]","(","https",":","\/\/arxiv.org\/abs\/2212.10554v1",")",".","This","applies","an","exponential","decay","to","the","RoPE","rotation","matrix",".","Args",":","dim","(","int",")",":","Embedding","dimension",".","smoothing","(","float",")",":","Smoothing","factor","applied","to","the","decay","rates",".","base_scale","(","int",")",":","Base","decay","rate",",","given","in","terms","of","scaling","time",".","device","(","torch.device",",","optional",")",":","Device","on","which","to","initialize","the","module",".","dtype","(","torch.dtype",")",":","dtype","to","use","to","generate","the","embedding","."]
docstr: Create complex decay tensor, cache values for fast computation.
docstr_tok: ["Create","complex","decay","tensor",",","cache","values","for","fast","computation","."]
code: def get_decay(self, start: int, end: int):
      """Create complex decay tensor, cache values for fast computation."""
      if self.decay is None or end > self.decay.shape[0]:
          assert isinstance(
              self.decay_rates, torch.Tensor
          )  # Satisfy type checker.
          idx = torch.arange(
              end, device=self.decay_rates.device, dtype=self.dtype
          )
          power = idx / self.base_scale
          scale = self.decay_rates ** power.unsqueeze(-1)
          self.decay = torch.polar(scale, torch.zeros_like(scale))
      return self.decay[start:end]
  
file_path: audiocraft/audiocraft/modules/rope.py
imports: import typing
  from torch import nn
  import torch
label_desc: Use image node_id 2 for calling the XPos obj's underlying member method code with example usage: obj.get_decay(start, end) and returns: self