code: def test_compatibility():
      """Regression test for #1121"""
      x = torch.rand(2, 3, 4)
  
      legacy_net = torch.nn.Sequential(
          LegacyPositionalEncoding(4, 0.0), torch.nn.Linear(4, 2)
      )
  
      latest_net = torch.nn.Sequential(
          PositionalEncoding(4, 0.0), torch.nn.Linear(4, 2)
      )
  
      latest_net.load_state_dict(legacy_net.state_dict())
      legacy = legacy_net(x)
      latest = latest_net(x)
      assert torch.allclose(legacy, latest)
  
      legacy_net = torch.nn.Sequential(
          LegacyScaledPositionalEncoding(4, 0.0), torch.nn.Linear(4, 2)
      )
  
      latest_net = torch.nn.Sequential(
          ScaledPositionalEncoding(4, 0.0), torch.nn.Linear(4, 2)
      )
  
      latest_net.load_state_dict(legacy_net.state_dict())
      legacy = legacy_net(x)
      latest = latest_net(x)
      assert torch.allclose(legacy, latest)
  
file_path: espnet/test/test_positional_encoding.py
imports: import pytest
  import torch
  from espnet.nets.pytorch_backend.transformer.embedding import LearnableFourierPosEnc, PositionalEncoding, ScaledPositionalEncoding
label_desc: Use image node_id 4 for calling a global function with example usage: test_compatibility() without return types