class_docstr: Language generation pipeline using any `ModelWithLMHead`. This pipeline predicts the words that will follow a
  specified text prompt.
  
  Example:
  
  ```python
  >>> from transformers import pipeline
  
  >>> generator = pipeline(model="gpt2")
  >>> generator("I can't believe you did such a ", do_sample=False)
  [{'generated_text': "I can't believe you did such a icky thing to me. I'm so sorry. I'm so sorry. I'm so sorry. I'm so sorry. I'm so sorry. I'm so sorry. I'm so sorry. I"}]
  
  >>> # These parameters will return suggestions, and only the newly created text making it easier for prompting suggestions.
  >>> outputs = generator("My tart needs some", num_return_sequences=4, return_full_text=False)
  ```
  
  Learn more about the basics of using a pipeline in the [pipeline tutorial](../pipeline_tutorial). You can pass text
  generation parameters to this pipeline to control stopping criteria, decoding strategy, and more. Learn more about
  text generation parameters in [Text generation strategies](../generation_strategies) and [Text
  generation](text_generation).
  
  This language generation pipeline can currently be loaded from [`pipeline`] using the following task identifier:
  `"text-generation"`.
  
  The models that this pipeline can use are models that have been trained with an autoregressive language modeling
  objective, which includes the uni-directional models in the library (e.g. gpt2). See the list of available models
  on [huggingface.co/models](https://huggingface.co/models?filter=text-generation).
class_docstr_tok: ["Language","generation","pipeline","using","any","`","ModelWithLMHead","`",".","This","pipeline","predicts","the","words","that","will","follow","a","specified","text","prompt",".","Example",":","``","`","python",">",">",">","from","transformers","import","pipeline",">",">",">","generator","=","pipeline","(","model=","''","gpt2","''",")",">",">",">","generator","(","``","I","ca","n't","believe","you","did","such","a","``",",","do_sample=False",")","[","{","'generated_text","'",":","``","I","ca","n't","believe","you","did","such","a","icky","thing","to","me",".","I","'m","so","sorry",".","I","'m","so","sorry",".","I","'m","so","sorry",".","I","'m","so","sorry",".","I","'m","so","sorry",".","I","'m","so","sorry",".","I","'m","so","sorry",".","I","''","}","]",">",">",">","#","These","parameters","will","return","suggestions",",","and","only","the","newly","created","text","making","it","easier","for","prompting","suggestions",".",">",">",">","outputs","=","generator","(","``","My","tart","needs","some","''",",","num_return_sequences=4",",","return_full_text=False",")","``","`","Learn","more","about","the","basics","of","using","a","pipeline","in","the","[","pipeline","tutorial","]","(","..","\/pipeline_tutorial",")",".","You","can","pass","text","generation","parameters","to","this","pipeline","to","control","stopping","criteria",",","decoding","strategy",",","and","more",".","Learn","more","about","text","generation","parameters","in","[","Text","generation","strategies","]","(","..","\/generation_strategies",")","and","[","Text","generation","]","(","text_generation",")",".","This","language","generation","pipeline","can","currently","be","loaded","from","[","`","pipeline","`","]","using","the","following","task","identifier",":","`","``","text-generation","''","`",".","The","models","that","this","pipeline","can","use","are","models","that","have","been","trained","with","an","autoregressive","language","modeling","objective",",","which","includes","the","uni-directional","models","in","the","library","(","e.g",".","gpt2",")",".","See","the","list","of","available","models","on","[","huggingface.co\/models","]","(","https",":","\/\/huggingface.co\/models","?","filter=text-generation",")","."]
code: def _sanitize_parameters(
      self,
      return_full_text=None,
      return_tensors=None,
      return_text=None,
      return_type=None,
      clean_up_tokenization_spaces=None,
      prefix=None,
      handle_long_generation=None,
      stop_sequence=None,
      add_special_tokens=False,
      truncation=None,
      padding=False,
      max_length=None,
      **generate_kwargs,
  ):
      preprocess_params = {
          "add_special_tokens": add_special_tokens,
          "truncation": truncation,
          "padding": padding,
          "max_length": max_length,
      }
      if max_length is not None:
          generate_kwargs["max_length"] = max_length
  
      if prefix is not None:
          preprocess_params["prefix"] = prefix
      if prefix:
          prefix_inputs = self.tokenizer(
              prefix,
              padding=False,
              add_special_tokens=add_special_tokens,
              return_tensors=self.framework,
          )
          generate_kwargs["prefix_length"] = prefix_inputs[
              "input_ids"
          ].shape[-1]
  
      if handle_long_generation is not None:
          if handle_long_generation not in {"hole"}:
              raise ValueError(
                  f"{handle_long_generation} is not a valid value for `handle_long_generation` parameter expected"
                  " [None, 'hole']"
              )
          preprocess_params[
              "handle_long_generation"
          ] = handle_long_generation
  
      preprocess_params.update(generate_kwargs)
      forward_params = generate_kwargs
  
      postprocess_params = {}
      if return_full_text is not None and return_type is None:
          if return_text is not None:
              raise ValueError(
                  "`return_text` is mutually exclusive with `return_full_text`"
              )
          if return_tensors is not None:
              raise ValueError(
                  "`return_full_text` is mutually exclusive with `return_tensors`"
              )
          return_type = (
              ReturnType.FULL_TEXT
              if return_full_text
              else ReturnType.NEW_TEXT
          )
      if return_tensors is not None and return_type is None:
          if return_text is not None:
              raise ValueError(
                  "`return_text` is mutually exclusive with `return_tensors`"
              )
          return_type = ReturnType.TENSORS
      if return_type is not None:
          postprocess_params["return_type"] = return_type
      if clean_up_tokenization_spaces is not None:
          postprocess_params[
              "clean_up_tokenization_spaces"
          ] = clean_up_tokenization_spaces
  
      if stop_sequence is not None:
          stop_sequence_ids = self.tokenizer.encode(
              stop_sequence, add_special_tokens=False
          )
          if len(stop_sequence_ids) > 1:
              warnings.warn(
                  "Stopping on a multiple token sequence is not yet supported on transformers. The first token of"
                  " the stop sequence will be used as the stop sequence string in the interim."
              )
          generate_kwargs["eos_token_id"] = stop_sequence_ids[0]
  
      return preprocess_params, forward_params, postprocess_params
  
file_path: transformers/src/transformers/pipelines/text_generation.py
imports: import enum
  import warnings
  from ..utils import add_end_docstrings, is_tf_available, is_torch_available
  from .base import PIPELINE_INIT_ARGS, Pipeline
label_desc: Use image node_id 2 for calling the TextGenerationPipeline obj's underlying member method code with example usage: obj._sanitize_parameters(return_full_text, return_tensors, return_text, return_type, clean_up_tokenization_spaces, prefix, handle_long_generation, stop_sequence, add_special_tokens, truncation, padding, max_length) and returns: preprocess_params,  forward_params,  postprocess_params