code: def test_extract_feature(self):
      model = conformer_wav2vec2_base()
      model.eval()
  
      batch_size, num_frames, in_features = 3, 1024, 64
      num_layers = len(model.encoder.conformer)
  
      features = torch.randn(batch_size, num_frames, in_features)
      lengths = torch.randint(
          low=0,
          high=num_frames,
          size=[
              batch_size,
          ],
      )
  
      all_features, lengths_ = model.extract_features(
          features, lengths, num_layers=None
      )
      assert len(all_features) == num_layers
      for feats in all_features:
          assert feats.ndim == 3
          assert feats.shape[0] == batch_size
      assert lengths_.shape == torch.Size([batch_size])
  
      for l in range(1, num_layers + 1):
          feats, lengths_ = model.extract_features(
              features, lengths, num_layers=l
          )
          assert len(feats) == l
          for i in range(l):
              self.assertEqual(all_features[i], feats[i])
          assert lengths_.shape == torch.Size([batch_size])
  
file_path: audio/test/torchaudio_unittest/prototype/conformer_wav2vec2_test.py
imports: import torch
  from parameterized import parameterized
  from torchaudio.prototype.models import conformer_wav2vec2_base, conformer_wav2vec2_pretrain_base, conformer_wav2vec2_pretrain_large
  from torchaudio_unittest.common_utils import disabledInCI, nested_params, skipIfNoCuda, torch_script, TorchaudioTestCase
label_desc: Use image node_id 6 for calling the TestConformerWav2Vec2 obj's underlying member method code with example usage: obj.test_extract_feature() without return types