code: def test_sru_backward(bidirectional, layer_norm, normalize_after):
      eps = 1e-4
      torch.manual_seed(123)
      torch.backends.cudnn.deterministic = True
      torch.backends.cudnn.benchmark = False
  
      input_length = 3
      batch_size = 5
      input_size = 4
      hidden_size = 2
      encoder = sru.SRU(
          input_size,
          hidden_size,
          bidirectional=bidirectional,
          layer_norm=layer_norm,
          normalize_after=normalize_after,
      )
      x = torch.randn(input_length, batch_size, input_size)
  
      # backward in CPU mode
      h, c = encoder(x)
      h.sum().backward()
      grads = [
          p.grad.clone()
          for p in encoder.parameters()
          if p.requires_grad
      ]
  
      # backward in GPU mode
      encoder.zero_grad()
      encoder, x = encoder.cuda(), x.cuda()
      h_, c_ = encoder(x)
      h_.sum().backward()
      grads_ = [
          p.grad.cpu().clone()
          for p in encoder.parameters()
          if p.requires_grad
      ]
  
      assert len(grads) == len(grads_)
      for g1, g2 in zip(grads, grads_):
          assert (g1 - g2).abs().max() <= eps
  
imports: import pytest
  import sru
  import torch
label_desc: Use image node_id 3 for calling a global function with example usage: test_sru_backward(bidirectional, layer_norm, normalize_after) without return types