code: def test_equivalence_flax_to_pt(self):
      (
          config,
          inputs_dict,
      ) = self.model_tester.prepare_config_and_inputs_for_common()
  
      for model_class in self.all_model_classes:
          with self.subTest(model_class.__name__):
              # Output all for aggressive testing
              config.output_hidden_states = True
              config.output_attentions = self.has_attentions
  
              # prepare inputs
              prepared_inputs_dict = self._prepare_for_class(
                  inputs_dict, model_class
              )
              pt_inputs = {
                  k: torch.tensor(v.tolist(), device=torch_device)
                  for k, v in prepared_inputs_dict.items()
              }
  
              # load corresponding PyTorch class
              pt_model_class_name = model_class.__name__[
                  4:
              ]  # Skip the "Flax" at the beginning
              pt_model_class = getattr(
                  transformers, pt_model_class_name
              )
  
              pt_model = pt_model_class(config).eval()
              # Flax models don't use the `use_cache` option and cache is not returned as a default.
              # So we disable `use_cache` here for PyTorch model.
              pt_model.config.use_cache = False
              fx_model = model_class(config, dtype=jnp.float32)
  
              pt_model = load_flax_weights_in_pytorch_model(
                  pt_model, fx_model.params
              )
  
              # make sure weights are tied in PyTorch
              pt_model.tie_weights()
  
              # send pytorch model to the correct device
              pt_model.to(torch_device)
  
              with torch.no_grad():
                  pt_outputs = pt_model(**pt_inputs)
              fx_outputs = fx_model(**prepared_inputs_dict)
  
              fx_keys = tuple(
                  [k for k, v in fx_outputs.items() if v is not None]
              )
              pt_keys = tuple(
                  [k for k, v in pt_outputs.items() if v is not None]
              )
  
              self.assertEqual(fx_keys, pt_keys)
              self.check_pt_flax_outputs(
                  fx_outputs, pt_outputs, model_class
              )
  
              with tempfile.TemporaryDirectory() as tmpdirname:
                  fx_model.save_pretrained(tmpdirname)
                  pt_model_loaded = pt_model_class.from_pretrained(
                      tmpdirname, from_flax=True
                  )
  
              # send pytorch model to the correct device
              pt_model_loaded.to(torch_device)
              pt_model_loaded.eval()
  
              with torch.no_grad():
                  pt_outputs_loaded = pt_model_loaded(**pt_inputs)
  
              fx_keys = tuple(
                  [k for k, v in fx_outputs.items() if v is not None]
              )
              pt_keys = tuple(
                  [
                      k
                      for k, v in pt_outputs_loaded.items()
                      if v is not None
                  ]
              )
  
              self.assertEqual(fx_keys, pt_keys)
              self.check_pt_flax_outputs(
                  fx_outputs, pt_outputs_loaded, model_class
              )
  
imports: import copy
  import inspect
  import json
  import random
  import tempfile
  from typing import List, Tuple
  import numpy
  import transformers
  from transformers import is_flax_available, is_torch_available
  from transformers.models.auto import get_values
  from transformers.testing_utils import CaptureLogger, is_pt_flax_cross_test, require_flax, torch_device
  from transformers.utils import CONFIG_NAME, GENERATION_CONFIG_NAME, logging
  from transformers.utils.generic import ModelOutput
label_desc: Use image node_id 6 for calling the FlaxModelTesterMixin obj's underlying member method code with example usage: obj.test_equivalence_flax_to_pt() without return types