class_docstr: Fused RoPE function for `thd` format.
  
  This implementation accepts arbitrary memory layouts to avoid the expensive
  `.contiguous()` calls, thus it may not achieve the best memory access pattern.
class_docstr_tok: ["Fused","RoPE","function","for","`","thd","`","format",".","This","implementation","accepts","arbitrary","memory","layouts","to","avoid","the","expensive","`",".contiguous","(",")","`","calls",",","thus","it","may","not","achieve","the","best","memory","access","pattern","."]
code: def backward(
      ctx, grad_output: torch.Tensor
  ) -> Tuple[Union[torch.Tensor, None], ...]:
      import fused_rotary_positional_embedding
  
      cu_seqlens, freqs = ctx.saved_tensors
      grad_input = fused_rotary_positional_embedding.backward_thd(
          grad_output, cu_seqlens, freqs
      )
  
      return grad_input, None, None
  
file_path: apex/apex/transformer/functional/fused_rope.py
imports: from typing import Tuple, Union
  import torch
label_desc: Use image node_id 2 for calling the FusedRoPETHDFunc obj's underlying member method code with example usage: obj.backward(ctx, grad_output) and returns: grad_input,  None,  None