code: def backward(self, grad_h, grad_last):
      if self.bidirectional:
          grad_last = torch.cat((grad_last[0], grad_last[1]), 1)
      bidir = 2 if self.bidirectional else 1
      u, x, bias, init, mask_h = self.saved_tensors
      c = self.intermediate
      length = x.size(0) if x.dim() == 3 else 1
      batch = x.size(-2)
      d = self.d_out
      k = u.size(-1) // d
      k_ = k // 2 if self.bidirectional else k
      ncols = batch * d * bidir
      thread_per_block = min(512, ncols)
      num_block = (ncols - 1) // thread_per_block + 1
  
      init_ = x.new(ncols).zero_() if init is None else init
      grad_u = u.new(*u.size())
      grad_bias = x.new(2, batch, d * bidir)
      grad_init = x.new(batch, d * bidir)
  
      # For DEBUG
      # size = (length, batch, x.size(-1)) \
      #         if x.dim() == 3 else (batch, x.size(-1))
      # grad_x = x.new(*x.size()) if k_ == 3 else x.new(*size).zero_()
  
      # Normal use
      grad_x = x.new(*x.size()) if k_ == 3 else None
  
      FUNC = SRU_BWD_FUNC if not self.bidirectional else SRU_BiBWD_FUNC
      FUNC(
          args=[
              u.contiguous().data_ptr(),
              x.contiguous().data_ptr() if k_ == 3 else 0,
              bias.data_ptr(),
              init_.contiguous().data_ptr(),
              mask_h.data_ptr() if mask_h is not None else 0,
              c.data_ptr(),
              grad_h.contiguous().data_ptr(),
              grad_last.contiguous().data_ptr(),
              length,
              batch,
              d,
              k_,
              grad_u.data_ptr(),
              grad_x.data_ptr() if k_ == 3 else 0,
              grad_bias.data_ptr(),
              grad_init.data_ptr(),
              self.activation_type,
          ],
          block=(thread_per_block, 1, 1),
          grid=(num_block, 1, 1),
          stream=SRU_STREAM,
      )
      return grad_u, grad_x, grad_bias.sum(1).view(-1), grad_init, None
  
imports: import subprocess
  import platform
  import os
  import re
  import configargparse
  import torch
  import torch.nn
  from torch.autograd import Function
  from torch.cuda.amp import custom_fwd, custom_bwd
  from collections import namedtuple
label_desc: Use image node_id 4 for calling the SRU_Compute obj's underlying member method code with example usage: obj.backward(grad_h, grad_last) and returns: grad_u,  grad_x,  grad_bias,  grad_init,  None