code: def run_pipeline_test(self, text_classifier, _):
      model = text_classifier.model
      # Small inputs because BartTokenizer tiny has maximum position embeddings = 22
      valid_inputs = "HuggingFace is in"
      outputs = text_classifier(valid_inputs)
  
      self.assertEqual(
          nested_simplify(outputs),
          [{"label": ANY(str), "score": ANY(float)}],
      )
      self.assertTrue(
          outputs[0]["label"] in model.config.id2label.values()
      )
  
      valid_inputs = ["HuggingFace is in ", "Paris is in France"]
      outputs = text_classifier(valid_inputs)
      self.assertEqual(
          nested_simplify(outputs),
          [
              {"label": ANY(str), "score": ANY(float)},
              {"label": ANY(str), "score": ANY(float)},
          ],
      )
      self.assertTrue(
          outputs[0]["label"] in model.config.id2label.values()
      )
      self.assertTrue(
          outputs[1]["label"] in model.config.id2label.values()
      )
  
      # Forcing to get all results with `top_k=None`
      # This is NOT the legacy format
      outputs = text_classifier(valid_inputs, top_k=None)
      N = len(model.config.id2label.values())
      self.assertEqual(
          nested_simplify(outputs),
          [
              [{"label": ANY(str), "score": ANY(float)}] * N,
              [{"label": ANY(str), "score": ANY(float)}] * N,
          ],
      )
  
      valid_inputs = {
          "text": "HuggingFace is in ",
          "text_pair": "Paris is in France",
      }
      outputs = text_classifier(valid_inputs)
      self.assertEqual(
          nested_simplify(outputs),
          {"label": ANY(str), "score": ANY(float)},
      )
      self.assertTrue(
          outputs["label"] in model.config.id2label.values()
      )
  
      # This might be used a text pair, but tokenizer + pipe interaction
      # makes it hard to understand that it's not using the pair properly
      # https://github.com/huggingface/transformers/issues/17305
      # We disabled this usage instead as it was outputting wrong outputs.
      invalid_input = [["HuggingFace is in ", "Paris is in France"]]
      with self.assertRaises(ValueError):
          text_classifier(invalid_input)
  
      # This used to be valid for doing text pairs
      # We're keeping it working because of backward compatibility
      outputs = text_classifier(
          [[["HuggingFace is in ", "Paris is in France"]]]
      )
      self.assertEqual(
          nested_simplify(outputs),
          [{"label": ANY(str), "score": ANY(float)}],
      )
      self.assertTrue(
          outputs[0]["label"] in model.config.id2label.values()
      )
  
file_path: transformers/tests/pipelines/test_pipelines_text_classification.py
imports: import unittest
  from transformers import MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING, TF_MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING, TextClassificationPipeline, pipeline
  from transformers.testing_utils import is_pipeline_test, nested_simplify, require_tf, require_torch, slow, torch_device
  from .test_pipelines_common import ANY
label_desc: Use image node_id 7 for calling the TextClassificationPipelineTests obj's underlying member method code with example usage: obj.run_pipeline_test(text_classifier, _) without return types