code: def __init__(
      self, dim, max_position_embeddings=2048, base=10000, device=None
  ):
      super().__init__()
  
      self.dim = dim
      self.max_position_embeddings = max_position_embeddings
      self.base = base
      inv_freq = 1.0 / (
          self.base
          ** (
              torch.arange(0, self.dim, 2).float().to(device) / self.dim
          )
      )
      self.register_buffer("inv_freq", inv_freq, persistent=False)
  
      # Build here to make `torch.jit.trace` work.
      self._set_cos_sin_cache(
          seq_len=max_position_embeddings,
          device=self.inv_freq.device,
          dtype=torch.get_default_dtype(),
      )
  
imports: from typing import Optional, Tuple, Union
  import torch
  import torch.utils.checkpoint
  from torch import Tensor, nn
  from torch.nn import CrossEntropyLoss
  from ...activations import ACT2FN
  from ...file_utils import add_start_docstrings, add_start_docstrings_to_model_forward, replace_return_docstrings
  from ...modeling_outputs import BaseModelOutputWithPast, CausalLMOutputWithPast
  from ...modeling_utils import PreTrainedModel
  from ...utils import logging
  from .configuration_gpt_neox_japanese import GPTNeoXJapaneseConfig
label_desc: Use image node_id 1 to create a new RotaryEmbedding object from inherited base classes: nn with example: obj = RotaryEmbedding(dim, max_position_embeddings, base, device)