code: def test_logits(self):
      model = TFOPTForCausalLM.from_pretrained(self.path_model)
      tokenizer = GPT2Tokenizer.from_pretrained(self.path_model)
  
      prompts = [
          "Today is a beautiful day and I want to",
          "In the city of",
          "Paris is the capital of France and",
          "Computers and mobile phones have taken",
      ]
      # verify that prompt without BOS token is identical to Metaseq -> add_special_tokens=False
      inputs = tokenizer(
          prompts,
          return_tensors="tf",
          padding=True,
          add_special_tokens=False,
      )
      logits = tf.math.reduce_mean(
          model(inputs.input_ids, attention_mask=inputs.attention_mask)[
              0
          ],
          axis=-1,
      )
      logits_meta = tf.constant(
          [
              [
                  1.3851,
                  -13.8923,
                  -10.5229,
                  -10.7533,
                  -0.2309,
                  -10.2384,
                  -0.5365,
                  -9.0947,
                  -5.1670,
              ],
              [
                  -4.7073,
                  -10.6276,
                  -3.9415,
                  -21.5242,
                  -0.2822,
                  -0.2822,
                  -0.2822,
                  -0.2822,
                  -0.2822,
              ],
              [
                  0.6247,
                  -3.4229,
                  -8.9179,
                  -1.4297,
                  -14.1650,
                  1.4146,
                  -9.0218,
                  -0.2703,
                  -0.2703,
              ],
              [
                  6.4783,
                  -1.9913,
                  -10.7926,
                  -2.3336,
                  1.5092,
                  -0.9974,
                  -6.8213,
                  1.3477,
                  1.3477,
              ],
          ]
      )
      self.assertTrue(np.allclose(logits, logits_meta, atol=1e-4))
  
      xla_generate = tf.function(model, jit_compile=True)
      logits = tf.math.reduce_mean(
          xla_generate(
              inputs.input_ids, attention_mask=inputs.attention_mask
          )[0],
          axis=-1,
      )
      self.assertTrue(np.allclose(logits, logits_meta, atol=1e-4))
  
imports: from __future__ import annotations
  import unittest
  import numpy
  from transformers import OPTConfig, is_tf_available
  from transformers.testing_utils import require_sentencepiece, require_tf, slow
  from ...test_configuration_common import ConfigTester
  from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor
  from ...test_pipeline_mixin import PipelineTesterMixin
label_desc: Use image node_id 2 for calling the TFOPTEmbeddingsTest obj's underlying member method code with example usage: obj.test_logits() without return types