code: def _set_cos_sin_cache(self, seq_len, device, dtype):
      self.max_seq_len_cached = seq_len
      t = torch.arange(
          self.max_seq_len_cached,
          device=device,
          dtype=self.inv_freq.dtype,
      )
  
      freqs = torch.outer(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().to(dtype), persistent=False
      )
      self.register_buffer(
          "sin_cached", emb.sin().to(dtype), 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 ...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 PersimmonRotaryEmbedding obj's underlying member method code with example usage: obj._set_cos_sin_cache(seq_len, device, dtype) without return types