code: def test_forward_works(self) -> None:
      m = SinusoidalPositionEncoder(
          encoding_dim=4, max_seq_len=10, device=device
      )
  
      x = torch.randn((3, 9, 4), device=device)
  
      y = m(x, padding_mask=None)
  
      assert y.shape == (3, 9, 4)
  
      assert_close(y - x, m.freqs[:9].expand_as(y))
  
      # Test with multiple batch dimensions.
      x = torch.randn((4, 3, 9, 4), device=device)
  
      y = m(x, padding_mask=None)
  
      assert y.shape == (4, 3, 9, 4)
  
      assert_close(y - x, m.freqs[:9].expand_as(y))
  
imports: import pytest
  import torch
  from torch import Tensor
  from fairseq2.nn import IncrementalStateBag, LearnedPositionEncoder, RotaryEncoder, SinusoidalPositionEncoder
  from tests.common import assert_close, device, tmp_rng_seed
label_desc: Use image node_id 4 for calling the TestSinusoidalPositionEncoder obj's underlying member method code with example usage: obj.test_forward_works() without return types