docstr: Logits testing to check implementation consistency between `fairseq` implementation
  and `transformers` implementation of NLLB-MoE transformers. We only check the logits
  of the second sample of the batch, as it is padded.
docstr_tok: ["Logits","testing","to","check","implementation","consistency","between","`","fairseq","`","implementation","and","`","transformers","`","implementation","of","NLLB-MoE","transformers",".","We","only","check","the","logits","of","the","second","sample","of","the","batch",",","as","it","is","padded","."]
code: def test_inference_logits(self):
      r"""
      Logits testing to check implementation consistency between `fairseq` implementation
      and `transformers` implementation of NLLB-MoE transformers. We only check the logits
      of the second sample of the batch, as it is padded.
      """
      model = NllbMoeForConditionalGeneration.from_pretrained(
          "hf-internal-testing/random-nllb-moe-2-experts"
      ).eval()
      with torch.no_grad():
          output = model(**self.model_inputs)
  
      EXPECTED_LOGTIS = torch.Tensor([-0.3059, 0.0000, 9.3029, 0.6456, -0.9148, 1.7836, 0.6478, 0.9438, -0.5272, -0.6617, -1.2717, 0.4564, 0.1345, -0.2301, -1.0140, 1.1427, -1.5535, 0.1337, 0.2082, -0.8112, -0.3842, -0.3377, 0.1256, 0.6450, -0.0452, 0.0219, 1.4274, -0.4991, -0.2063, -0.4409,])  # fmt: skip
      torch.testing.assert_allclose(
          output.logits[1, 0, :30],
          EXPECTED_LOGTIS,
          rtol=6e-3,
          atol=9e-3,
      )
  
imports: import copy
  import tempfile
  import unittest
  from transformers import NllbMoeConfig, is_torch_available, set_seed
  from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, require_torch_fp16, slow, torch_device
  from transformers.utils import cached_property
  from ...generation.test_utils import GenerationTesterMixin
  from ...test_configuration_common import ConfigTester
  from ...test_modeling_common import ModelTesterMixin, ids_tensor
  from ...test_pipeline_mixin import PipelineTesterMixin
label_desc: Use image node_id 5 for calling the NllbMoeModelIntegrationTests obj's underlying member method code with example usage: obj.test_inference_logits() without return types