class_docstr: Constructs a PIX2STRUCT processor which wraps a BERT tokenizer and PIX2STRUCT image processor into a single
  processor.
  
  [`Pix2StructProcessor`] offers all the functionalities of [`Pix2StructImageProcessor`] and [`T5TokenizerFast`]. See
  the docstring of [`~Pix2StructProcessor.__call__`] and [`~Pix2StructProcessor.decode`] for more information.
  
  Args:
      image_processor (`Pix2StructImageProcessor`):
          An instance of [`Pix2StructImageProcessor`]. The image processor is a required input.
      tokenizer (Union[`T5TokenizerFast`, `T5Tokenizer`]):
          An instance of ['T5TokenizerFast`] or ['T5Tokenizer`]. The tokenizer is a required input.
class_docstr_tok: ["Constructs","a","PIX2STRUCT","processor","which","wraps","a","BERT","tokenizer","and","PIX2STRUCT","image","processor","into","a","single","processor",".","[","`","Pix2StructProcessor","`","]","offers","all","the","functionalities","of","[","`","Pix2StructImageProcessor","`","]","and","[","`","T5TokenizerFast","`","]",".","See","the","docstring","of","[","`","~Pix2StructProcessor.__call__","`","]","and","[","`","~Pix2StructProcessor.decode","`","]","for","more","information",".","Args",":","image_processor","(","`","Pix2StructImageProcessor","`",")",":","An","instance","of","[","`","Pix2StructImageProcessor","`","]",".","The","image","processor","is","a","required","input",".","tokenizer","(","Union","[","`","T5TokenizerFast","`",",","`","T5Tokenizer","`","]",")",":","An","instance","of","[","'T5TokenizerFast","`","]","or","[","'T5Tokenizer","`","]",".","The","tokenizer","is","a","required","input","."]
docstr: This method uses [`Pix2StructImageProcessor.preprocess`] method to prepare image(s) for the model, and
  [`T5TokenizerFast.__call__`] to prepare text for the model.
  
  Please refer to the docstring of the above two methods for more information.
docstr_tok: ["This","method","uses","[","`","Pix2StructImageProcessor.preprocess","`","]","method","to","prepare","image","(","s",")","for","the","model",",","and","[","`","T5TokenizerFast.__call__","`","]","to","prepare","text","for","the","model",".","Please","refer","to","the","docstring","of","the","above","two","methods","for","more","information","."]
code: def __call__(
      self,
      images=None,
      text: Union[
          TextInput,
          PreTokenizedInput,
          List[TextInput],
          List[PreTokenizedInput],
      ] = None,
      add_special_tokens: bool = True,
      padding: Union[bool, str, PaddingStrategy] = False,
      truncation: Union[bool, str, TruncationStrategy] = None,
      max_length: Optional[int] = None,
      max_patches: Optional[int] = 2048,
      stride: int = 0,
      pad_to_multiple_of: Optional[int] = None,
      return_attention_mask: Optional[bool] = None,
      return_overflowing_tokens: bool = False,
      return_special_tokens_mask: bool = False,
      return_offsets_mapping: bool = False,
      return_token_type_ids: bool = False,
      return_length: bool = False,
      verbose: bool = True,
      return_tensors: Optional[Union[str, TensorType]] = None,
      **kwargs,
  ) -> BatchEncoding:
      """
      This method uses [`Pix2StructImageProcessor.preprocess`] method to prepare image(s) for the model, and
      [`T5TokenizerFast.__call__`] to prepare text for the model.
  
      Please refer to the docstring of the above two methods for more information.
      """
      if images is None and text is None:
          raise ValueError("You have to specify either images or text.")
  
      # Get only text
      if images is None and not self.image_processor.is_vqa:
          self.current_processor = self.tokenizer
          text_encoding = self.tokenizer(
              text=text,
              add_special_tokens=add_special_tokens,
              padding=padding,
              truncation=truncation,
              max_length=max_length,
              stride=stride,
              pad_to_multiple_of=pad_to_multiple_of,
              return_attention_mask=return_attention_mask,
              return_overflowing_tokens=return_overflowing_tokens,
              return_special_tokens_mask=return_special_tokens_mask,
              return_offsets_mapping=return_offsets_mapping,
              return_token_type_ids=return_token_type_ids,
              return_length=return_length,
              verbose=verbose,
              return_tensors=return_tensors,
              **kwargs,
          )
          return text_encoding
  
      if not self.image_processor.is_vqa:
          # add pixel_values
          encoding_image_processor = self.image_processor(
              images,
              return_tensors=return_tensors,
              max_patches=max_patches,
              **kwargs,
          )
      else:
          # add pixel_values and bbox
          encoding_image_processor = self.image_processor(
              images,
              return_tensors=return_tensors,
              max_patches=max_patches,
              header_text=text,
              **kwargs,
          )
  
      if text is not None and not self.image_processor.is_vqa:
          text_encoding = self.tokenizer(
              text=text,
              add_special_tokens=add_special_tokens,
              padding=padding,
              truncation=truncation,
              max_length=max_length,
              stride=stride,
              pad_to_multiple_of=pad_to_multiple_of,
              return_attention_mask=return_attention_mask,
              return_overflowing_tokens=return_overflowing_tokens,
              return_special_tokens_mask=return_special_tokens_mask,
              return_offsets_mapping=return_offsets_mapping,
              return_token_type_ids=return_token_type_ids,
              return_length=return_length,
              verbose=verbose,
              return_tensors=return_tensors,
              **kwargs,
          )
  
          if "attention_mask" in text_encoding:
              text_encoding[
                  "decoder_attention_mask"
              ] = text_encoding.pop("attention_mask")
          if "input_ids" in text_encoding:
              text_encoding["decoder_input_ids"] = text_encoding.pop(
                  "input_ids"
              )
      else:
          text_encoding = None
  
      if text_encoding is not None:
          encoding_image_processor.update(text_encoding)
  
      return encoding_image_processor
  
file_path: transformers/src/transformers/models/pix2struct/processing_pix2struct.py
imports: from typing import List, Optional, Union
  from ...processing_utils import ProcessorMixin
  from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy
  from ...utils import TensorType
label_desc: Use image node_id 2 for calling the Pix2StructProcessor obj's underlying member method code with example usage: obj.__call__(images, text, add_special_tokens, padding, truncation, max_length, max_patches, stride, pad_to_multiple_of, return_attention_mask, return_overflowing_tokens, return_special_tokens_mask, return_offsets_mapping, return_token_type_ids, return_length, verbose, return_tensors) and returns: encoding_image_processor, text_encoding