code: def apply_rotary_pos_emb_thd(
      t: torch.Tensor, cu_seqlens: torch.Tensor, freqs: torch.Tensor
  ) -> torch.Tensor:
      """A baseline implementation of applying RoPE for `thd` format.
  
      Args:
          t (Tensor): Input tensor T is of shape [t, h, d]
          cu_seqlens(Tensor):  Cumulative sum of sequence lengths in a batch for `t`,
          with shape [b + 1] and dtype torch.int32.
          freqs (Tensor): Rotary Positional embedding tensor freq is of shape [max_s, 1, 1, d]
  
      Returns:
          Tensor: Shape [t, h, d]. The input tensor after applying RoPE.
      """
      seqlens = (cu_seqlens[1:] - cu_seqlens[:-1]).tolist()
      return torch.cat(
          [
              apply_rotary_pos_emb(x.unsqueeze(1), freqs[: x.size(0)])
              for x in torch.split(t, seqlens)
          ]
      ).squeeze(1)
  
file_path: apex/tests/L0/run_transformer/test_fused_rope.py
imports: import itertools
  import torch
  from torch.testing._internal import common_utils
  from apex.transformer.functional import fused_apply_rotary_pos_emb, fused_apply_rotary_pos_emb_cached, fused_apply_rotary_pos_emb_thd
label_desc: Use image node_id 3 for calling a global function with example usage: apply_rotary_pos_emb_thd(t, cu_seqlens, freqs) and returns: torch