code: def test_length_adaptor_forward(input_layer, odim):
      idim = 200
      x_max_length = 50
      length_adaptor_n_layers = 1
      postencoder = LengthAdaptorPostEncoder(
          idim, length_adaptor_n_layers, input_layer, odim
      )
      x = torch.randn([4, x_max_length, idim], requires_grad=True)
      x_lengths = torch.LongTensor([20, 5, x_max_length, 15])
      y, y_lengths = postencoder(x, x_lengths)
      y.sum().backward()
  
      if odim is None:
          odim_expected = idim
      else:
          odim_expected = odim
  
      assert postencoder.output_size() == odim_expected
  
      y_shape_1_expected = x_max_length // 2**length_adaptor_n_layers
      y_lengths_expected = (
          x_lengths.float()
          .div(2**length_adaptor_n_layers)
          .floor()
          .long()
      )
  
      assert y.shape == torch.Size(
          [4, y_shape_1_expected, odim_expected]
      )
      assert torch.equal(y_lengths, y_lengths_expected)
  
imports: import pytest
  import torch
  from espnet2.asr.postencoder.length_adaptor_postencoder import LengthAdaptorPostEncoder
label_desc: Use image node_id 1 for calling a global function with example usage: test_length_adaptor_forward(input_layer, odim) without return types