code: def test_add():
      encoding = AddSinusoidalEncoding(d_model=10, max_len=4)
      x = torch.zeros(1, 4, 10)
      y = encoding(x)
  
      r = torch.randn(1, 4, 10)
      r2 = encoding(r)
  
      assert torch.allclose(r2 - r, y, atol=1e-07)
  
      r = torch.randn(2, 4, 10)
      r2 = encoding(r)
  
      assert torch.allclose(r2[0] - r[0], y, atol=1e-07)
      assert torch.allclose(r2[1] - r[1], y, atol=1e-07)
  
file_path: stanza/stanza/tests/constituency/test_positional_encoding.py
imports: import pytest
  import torch
  from stanza import Pipeline
  from stanza.models.constituency.positional_encoding import SinusoidalEncoding, AddSinusoidalEncoding
  from stanza.tests import *
label_desc: Use image node_id 4 for calling a global function with example usage: test_add() without return types