code: def test_pipeline_length_setting_warning(self):
      prompt = """Hello world"""
      text_generator = pipeline(
          "text-generation",
          model="hf-internal-testing/tiny-random-gpt2",
      )
      if text_generator.model.framework == "tf":
          logger = logging.get_logger(
              "transformers.generation.tf_utils"
          )
      else:
          logger = logging.get_logger("transformers.generation.utils")
      logger_msg = "Both `max_new_tokens`"  # The beggining of the message to be checked in this test
  
      # Both are set by the user -> log warning
      with CaptureLogger(logger) as cl:
          _ = text_generator(prompt, max_length=10, max_new_tokens=1)
      self.assertIn(logger_msg, cl.out)
  
      # The user only sets one -> no warning
      with CaptureLogger(logger) as cl:
          _ = text_generator(prompt, max_new_tokens=1)
      self.assertNotIn(logger_msg, cl.out)
  
      with CaptureLogger(logger) as cl:
          _ = text_generator(prompt, max_length=10)
      self.assertNotIn(logger_msg, cl.out)
  
file_path: transformers/tests/pipelines/test_pipelines_text_generation.py
imports: import unittest
  from transformers import MODEL_FOR_CAUSAL_LM_MAPPING, TF_MODEL_FOR_CAUSAL_LM_MAPPING, TextGenerationPipeline, logging, pipeline
  from transformers.testing_utils import CaptureLogger, is_pipeline_test, require_accelerate, require_tf, require_torch, require_torch_accelerator, require_torch_gpu, require_torch_or_tf, torch_device
  from .test_pipelines_common import ANY
label_desc: Use image node_id 9 for calling the TextGenerationPipelineTests obj's underlying member method code with example usage: obj.test_pipeline_length_setting_warning() without return types