class_docstr: WKVLinearAttention function definition.
docstr: WKVLinearAttention function backward pass.
  
  Args:
      grad_output: Output gradient. (B, U, D_att)
  
  Returns:
      grad_time_decay: Gradient for channel-wise time decay vector. (D_att)
      grad_time_first: Gradient for channel-wise time first vector. (D_att)
      grad_key: Gradient for key tensor. (B, U, D_att)
      grad_value: Gradient for value tensor. (B, U, D_att)
docstr_tok: ["WKVLinearAttention","function","backward","pass",".","Args",":","grad_output",":","Output","gradient",".","(","B",",","U",",","D_att",")","Returns",":","grad_time_decay",":","Gradient","for","channel-wise","time","decay","vector",".","(","D_att",")","grad_time_first",":","Gradient","for","channel-wise","time","first","vector",".","(","D_att",")","grad_key",":","Gradient","for","key","tensor",".","(","B",",","U",",","D_att",")","grad_value",":","Gradient","for","value","tensor",".","(","B",",","U",",","D_att",")"]
code: def backward(
      ctx, grad_output: torch.Tensor
  ) -> Tuple[torch.Tensor, torch.Tensor, torch.Tensor, torch.Tensor]:
      """WKVLinearAttention function backward pass.
  
      Args:
          grad_output: Output gradient. (B, U, D_att)
  
      Returns:
          grad_time_decay: Gradient for channel-wise time decay vector. (D_att)
          grad_time_first: Gradient for channel-wise time first vector. (D_att)
          grad_key: Gradient for key tensor. (B, U, D_att)
          grad_value: Gradient for value tensor. (B, U, D_att)
  
      """
      time_decay, time_first, key, value, output = ctx.saved_tensors
      grad_dtype = ctx.input_dtype
  
      batch, _, dim = key.size()
  
      grad_time_decay = torch.empty(
          (batch, dim),
          memory_format=torch.contiguous_format,
          dtype=time_decay.dtype,
          device=time_decay.device,
      )
  
      grad_time_first = torch.empty(
          (batch, dim),
          memory_format=torch.contiguous_format,
          dtype=time_decay.dtype,
          device=time_decay.device,
      )
  
      grad_key = torch.empty_like(
          key, memory_format=torch.contiguous_format
      )
      grad_value = torch.empty_like(
          value, memory_format=torch.contiguous_format
      )
  
      wkv_kernel.backward(
          time_decay,
          time_first,
          key,
          value,
          output,
          grad_output.contiguous(),
          grad_time_decay,
          grad_time_first,
          grad_key,
          grad_value,
      )
  
      grad_time_decay = torch.sum(grad_time_decay, dim=0)
      grad_time_first = torch.sum(grad_time_first, dim=0)
  
      return (
          grad_time_decay,
          grad_time_first,
          grad_key,
          grad_value,
      )
  
file_path: espnet/espnet2/asr_transducer/decoder/modules/rwkv/attention.py
imports: import math
  from importlib.util import find_spec
  from pathlib import Path
  from typing import List, Optional, Tuple, Union
  import torch
label_desc: Use image node_id 2 for calling the WKVLinearAttention obj's underlying member method code with example usage: obj.backward(ctx, grad_output) and returns: grad_time_decay,  grad_time_first,  grad_key,  grad_value