code: def forward(self, x, seq_len=None):
      # x: [bs, num_attention_heads, seq_len, head_size]
      # This `if` block is unlikely to be run after we build sin/cos
      # in `__init__`. Keep the logic here just in case.
      if seq_len > self.max_seq_len_cached:
          self.max_seq_len_cached = seq_len
          t = torch.arange(
              self.max_seq_len_cached,
              device=x.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).to(x.device)
          self.register_buffer(
              "cos_cached",
              emb.cos()[None, None, :, :],
              persistent=False,
          )
          self.register_buffer(
              "sin_cached",
              emb.sin()[None, None, :, :],
              persistent=False,
          )
      return (
          self.cos_cached[:, :, :seq_len, ...].to(dtype=x.dtype),
          self.sin_cached[:, :, :seq_len, ...].to(dtype=x.dtype),
      )
  
imports: from .configuration_baichuan import BaiChuanConfig
  from transformers import PreTrainedModel, add_start_docstrings
  from transformers.activations import ACT2FN
  from transformers.modeling_outputs import BaseModelOutputWithPast, CausalLMOutputWithPast, SequenceClassifierOutputWithPast
  from transformers.utils import logging, add_start_docstrings_to_model_forward, replace_return_docstrings
  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
label_desc: Use image node_id 2 for calling the RotaryEmbedding obj's underlying member method code with example usage: obj.forward(x, seq_len) and returns: self,  self