class_docstr: Multi-headed attention from 'Attention Is All You Need' paper
class_docstr_tok: ["Multi-headed","attention","from","'Attention","Is","All","You","Need","'","paper"]
code: def _init_rope(self):
      if self.config.rope_scaling is None:
          self.rotary_emb = PersimmonRotaryEmbedding(
              int(self.partial_rotary_factor * self.head_dim),
              max_position_embeddings=self.max_position_embeddings,
              base=self.rope_theta,
          )
      else:
          scaling_type = self.config.rope_scaling["type"]
          scaling_factor = self.config.rope_scaling["factor"]
          if scaling_type == "linear":
              self.rotary_emb = PersimmonLinearScalingRotaryEmbedding(
                  int(self.partial_rotary_factor * self.head_dim),
                  max_position_embeddings=self.max_position_embeddings,
                  scaling_factor=scaling_factor,
                  base=self.rope_theta,
              )
          elif scaling_type == "dynamic":
              self.rotary_emb = PersimmonDynamicNTKScalingRotaryEmbedding(
                  int(self.partial_rotary_factor * self.head_dim),
                  max_position_embeddings=self.max_position_embeddings,
                  scaling_factor=scaling_factor,
                  base=self.rope_theta,
              )
          else:
              raise ValueError(
                  f"Unknown RoPE scaling type {scaling_type}"
              )
  
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 ...activations import ACT2FN
  from ...cache_utils import Cache, DynamicCache
  from ...modeling_attn_mask_utils import _prepare_4d_causal_attention_mask
  from ...modeling_outputs import BaseModelOutputWithPast, CausalLMOutputWithPast, SequenceClassifierOutputWithPast
  from ...modeling_utils import PreTrainedModel
  from ...utils import add_start_docstrings, add_start_docstrings_to_model_forward, logging, replace_return_docstrings
  from .configuration_persimmon import PersimmonConfig
label_desc: Use image node_id 2 for calling the PersimmonAttention obj's underlying member method code with example usage: obj._init_rope() without return types