class_docstr: Testing suite for Audio models - tests all the tests defined in `BetterTransformersTestMixin`
docstr: This tests if the converted model produces the same logits
  than the original model.
docstr_tok: ["This","tests","if","the","converted","model","produces","the","same","logits","than","the","original","model","."]
code: def test_logits(self, model_type: str):
      r"""
      This tests if the converted model produces the same logits
      than the original model.
      """
      # The first row of the attention mask needs to be all ones -> check: https://github.com/pytorch/pytorch/blob/19171a21ee8a9cc1a811ac46d3abd975f0b6fc3b/test/test_nn.py#L5283
      model_ids = (
          MODELS_DICT[model_type]
          if isinstance(MODELS_DICT[model_type], tuple)
          else (MODELS_DICT[model_type],)
      )
      for model_id in model_ids:
          inputs = self.prepare_inputs_for_class(model_id, model_type)
  
          torch.manual_seed(0)
          hf_random_model = AutoModel.from_pretrained(model_id).eval()
          random_config = hf_random_model.config
  
          torch.manual_seed(0)
          converted_model = BetterTransformer.transform(hf_random_model)
  
          torch.manual_seed(0)
          hf_random_model = AutoModel.from_pretrained(model_id).eval()
          random_config = hf_random_model.config
  
          self.assertFalse(
              hasattr(hf_random_model, "use_bettertransformer"),
              f"The model {hf_random_model.__class__.__name__} has been converted to a `fast` model by mistake.",
          )
  
          with torch.no_grad():
              r"""
              Make sure the models are in eval mode! Make also sure that the original model
              has not been converted to a fast model. The check is done above.
              """
              torch.manual_seed(0)
              hf_hidden_states = hf_random_model(**inputs)[0]
  
              torch.manual_seed(0)
              bt_hidden_states = converted_model(**inputs)[0]
  
              if "gelu_new" in vars(random_config).values():
                  # Since `gelu_new` is a slightly modified version of `GeLU` we expect a small
                  # discrepency.
                  tol = 4e-2
              else:
                  tol = 1e-3
  
              self.assertTrue(
                  torch.allclose(
                      bt_hidden_states[0][-3:],
                      torch.zeros_like(bt_hidden_states[0][-3:]),
                  ),
                  "The BetterTransformers converted model does not give null hidden states on padded tokens",
              )
  
              self.assertTrue(
                  torch.allclose(
                      hf_hidden_states[-1],
                      bt_hidden_states[-1],
                      atol=tol,
                  ),
                  "The BetterTransformers Converted model does not produce the same logits as the original model. Failed for the model {}".format(
                      hf_random_model.__class__.__name__
                  ),
              )
  
imports: import unittest
  import numpy
  import pytest
  import torch
  from parameterized import parameterized
  from testing_utils import MODELS_DICT, BetterTransformersTestMixin
  from transformers import AutoModel, AutoProcessor, set_seed
  from optimum.bettertransformer import BetterTransformer
  from optimum.utils.testing_utils import grid_parameters, require_torch_gpu
label_desc: Use image node_id 2 for calling the BetterTransformersAudioTest obj's underlying member method code with example usage: obj.test_logits(model_type) without return types