code: def check_pt_tf_models(self, tf_model, pt_model, tf_inputs_dict):
      pt_inputs_dict = self.prepare_pt_inputs_from_tf_inputs(
          tf_inputs_dict
      )
  
      # send pytorch inputs to the correct device
      pt_inputs_dict = {
          k: v.to(device=torch_device)
          if isinstance(v, torch.Tensor)
          else v
          for k, v in pt_inputs_dict.items()
      }
  
      # send pytorch model to the correct device
      pt_model.to(torch_device)
  
      # Check predictions on first output (logits/hidden-states) are close enough given low-level computational differences
      pt_model.eval()
  
      with torch.no_grad():
          pt_outputs = pt_model(**pt_inputs_dict)
      tf_outputs = tf_model(tf_inputs_dict)
  
      # tf models returned loss is usually a tensor rather than a scalar.
      # (see `hf_compute_loss`: it uses `tf.keras.losses.Reduction.NONE`)
      # Change it here to a scalar to match PyTorch models' loss
      tf_loss = getattr(tf_outputs, "loss", None)
      if tf_loss is not None:
          tf_outputs.loss = tf.math.reduce_mean(tf_loss)
  
      self.check_pt_tf_outputs(tf_outputs, pt_outputs, type(tf_model))
  
imports: from __future__ import annotations
  import copy
  import os
  import tempfile
  import unittest
  import numpy
  from transformers import is_tf_available, is_torch_available, is_vision_available
  from transformers.testing_utils import is_pt_tf_cross_test, require_tf, require_torch, require_vision, slow, torch_device
  from transformers.utils.generic import ModelOutput
  from ...test_modeling_tf_common import floats_tensor, ids_tensor
  from ..gpt2.test_modeling_tf_gpt2 import TFGPT2ModelTester
  from ..vit.test_modeling_tf_vit import TFViTModelTester
label_desc: Use image node_id 13 for calling the TFVisionEncoderDecoderMixin obj's underlying member method code with example usage: obj.check_pt_tf_models(tf_model, pt_model, tf_inputs_dict) without return types