code: def test_forward_works_in_incremental_decode(
      self, step_nr: int
  ) -> None:
      m = LearnedPositionEncoder(
          encoding_dim=32, max_seq_len=4, device=device
      )
  
      state_bag = IncrementalStateBag(max_num_steps=3)
  
      state_bag.increment_step_nr(step_nr)
  
      seq_len = 2
  
      m.eval()
  
      x = torch.randn((5, seq_len, 32), device=device)
  
      y = m(x, padding_mask=None, state_bag=state_bag)
  
      assert y.shape == (5, seq_len, 32)
  
      assert_close(
          y - x, m.weight[step_nr : step_nr + seq_len].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 3 for calling the TestLearnedPositionEncoder obj's underlying member method code with example usage: obj.test_forward_works_in_incremental_decode(step_nr) without return types