code: def __init__(
      self, dim, max_position_embeddings=2048, base=10000, device=None
  ):
      super().__init__()
      inv_freq = 1.0 / (
          base ** (torch.arange(0, dim, 2).float().to(device) / dim)
      )
      self.register_buffer("inv_freq", inv_freq)
  
      # Build here to make `torch.jit.trace` work.
      self.max_seq_len_cached = max_position_embeddings
      t = torch.arange(
          self.max_seq_len_cached,
          device=self.inv_freq.device,
          dtype=self.inv_freq.dtype,
      )
      freqs = torch.einsum("i,j->ij", t, self.inv_freq)
      # Different from paper, but it uses a different permutation in order to obtain the same calculation
      emb = torch.cat((freqs, freqs), dim=-1)
      self.register_buffer(
          "cos_cached", emb.cos()[None, None, :, :], persistent=False
      )
      self.register_buffer(
          "sin_cached", emb.sin()[None, None, :, :], persistent=False
      )
  
imports: import math
  from typing import List, Optional, Tuple, Union
  import torch
  import torch.utils.checkpoint
  from torch import nn
  from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss
  from transformers.activations import ACT2FN
  from transformers.modeling_outputs import BaseModelOutputWithPast, CausalLMOutputWithPast, SequenceClassifierOutputWithPast
  from transformers.modeling_utils import PreTrainedModel
  from transformers.utils import add_start_docstrings, add_start_docstrings_to_model_forward, logging, replace_return_docstrings
  from transformers.models.llama.configuration_llama import LlamaConfig
label_desc: Use image node_id 1 to create a new LlamaRotaryEmbedding object from inherited base classes: torch.nn with example: obj = LlamaRotaryEmbedding(dim, max_position_embeddings, base, device)