code: def test_rag_token_inference_nq_checkpoint(self):
      rag_config = self.get_rag_config()
      rag_decoder_tokenizer = BartTokenizer.from_pretrained(
          "facebook/bart-large-cnn"
      )
      rag_question_encoder_tokenizer = (
          DPRQuestionEncoderTokenizer.from_pretrained(
              "facebook/dpr-question_encoder-single-nq-base"
          )
      )
      rag_retriever = RagRetriever(
          rag_config,
          question_encoder_tokenizer=rag_question_encoder_tokenizer,
          generator_tokenizer=rag_decoder_tokenizer,
      )
  
      rag_token = self.token_model_nq_checkpoint(
          retriever=rag_retriever
      )
  
      # check that outputs after saving and loading are equal
      with tempfile.TemporaryDirectory() as tmpdirname:
          rag_token.save_pretrained(tmpdirname)
          rag_token = TFRagTokenForGeneration.from_pretrained(
              tmpdirname, retriever=rag_retriever
          )
  
      input_ids = rag_question_encoder_tokenizer(
          "who sings does he love me with reba", return_tensors="tf"
      ).input_ids
      decoder_input_ids = rag_decoder_tokenizer(
          "Linda Davis", return_tensors="tf"
      ).input_ids
  
      output = rag_token(
          input_ids,
          labels=decoder_input_ids,
      )
  
      expected_shape = tf.TensorShape([5, 5, 50265])
      self.assertEqual(output.logits.shape, expected_shape)
  
      expected_doc_scores = tf.convert_to_tensor(
          [[62.9402, 62.7107, 62.2382, 62.1194, 61.8578]]
      )
      expected_loss = tf.convert_to_tensor([32.521812])
  
      tf.debugging.assert_near(output.loss, expected_loss, atol=1e-3)
      tf.debugging.assert_near(
          output.doc_scores, expected_doc_scores, atol=1e-3
      )
  
imports: import json
  import os
  import shutil
  import tempfile
  import unittest
  from unittest.mock import patch
  import numpy
  from transformers import BartTokenizer
  from transformers.models.bert.tokenization_bert import VOCAB_FILES_NAMES
  from transformers.models.dpr.tokenization_dpr import DPRQuestionEncoderTokenizer
  from transformers.models.roberta.tokenization_roberta import VOCAB_FILES_NAMES
  from transformers.testing_utils import require_sentencepiece, require_tf, require_tokenizers, slow
  from transformers.utils import cached_property, is_datasets_available, is_faiss_available, is_tf_available
  from ..bart.test_modeling_tf_bart import TFBartModelTester
  from ..dpr.test_modeling_tf_dpr import TFDPRModelTester
label_desc: Use image node_id 7 for calling the TFRagModelIntegrationTests obj's underlying member method code with example usage: obj.test_rag_token_inference_nq_checkpoint() without return types