from typing import List, Optional, Union

from ...image_utils import ImageInput
from ...processing_utils import ProcessorMixin
from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy
from ...utils import TensorType







class __snake_case       (		lowerCamelCase_	):
   lowerCAmelCase_														=							["image_processor", "tokenizer"]
   lowerCAmelCase_														=							"BlipImageProcessor"
   lowerCAmelCase_														=							("BertTokenizer", "BertTokenizerFast")




   def __init__(					self    :       Any ,			_lowercase    :       Optional[Any] ,			_lowercase    :       Optional[Any]   ):



     """simple docstring"""






     SCREAMING_SNAKE_CASE__    							=   False
     super().__init__(_lowercase ,			_lowercase   )
     SCREAMING_SNAKE_CASE__    							=   self.image_processor




   def __call__(					self    :       Any ,			_lowercase    :       ImageInput = None ,			_lowercase    :       Union[TextInput, PreTokenizedInput, List[TextInput], List[PreTokenizedInput]] = None ,			_lowercase    :       bool = True ,			_lowercase    :       Union[bool, str, PaddingStrategy] = False ,			_lowercase    :       Union[bool, str, TruncationStrategy] = None ,			_lowercase    :       Optional[int] = None ,			_lowercase    :       int = 0 ,			_lowercase    :       Optional[int] = None ,			_lowercase    :       Optional[bool] = None ,			_lowercase    :       bool = False ,			_lowercase    :       bool = False ,			_lowercase    :       bool = False ,			_lowercase    :       bool = False ,			_lowercase    :       bool = False ,			_lowercase    :       bool = True ,			_lowercase    :       Optional[Union[str, TensorType]] = None ,			**_lowercase    :       List[Any] ,			):



     """simple docstring"""






     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:
       SCREAMING_SNAKE_CASE__    							=   self.tokenizer
       SCREAMING_SNAKE_CASE__    							=   self.tokenizer(
           text=_lowercase ,			add_special_tokens=_lowercase ,			padding=_lowercase ,			truncation=_lowercase ,			max_length=_lowercase ,			stride=_lowercase ,			pad_to_multiple_of=_lowercase ,			return_attention_mask=_lowercase ,			return_overflowing_tokens=_lowercase ,			return_special_tokens_mask=_lowercase ,			return_offsets_mapping=_lowercase ,			return_token_type_ids=_lowercase ,			return_length=_lowercase ,			verbose=_lowercase ,			return_tensors=_lowercase ,			**_lowercase ,			)
       return text_encoding

     # add pixel_values
     SCREAMING_SNAKE_CASE__    							=   self.image_processor(_lowercase ,			return_tensors=_lowercase   )

     if text is not None:
       SCREAMING_SNAKE_CASE__    							=   self.tokenizer(
           text=_lowercase ,			add_special_tokens=_lowercase ,			padding=_lowercase ,			truncation=_lowercase ,			max_length=_lowercase ,			stride=_lowercase ,			pad_to_multiple_of=_lowercase ,			return_attention_mask=_lowercase ,			return_overflowing_tokens=_lowercase ,			return_special_tokens_mask=_lowercase ,			return_offsets_mapping=_lowercase ,			return_token_type_ids=_lowercase ,			return_length=_lowercase ,			verbose=_lowercase ,			return_tensors=_lowercase ,			**_lowercase ,			)
     else:
       SCREAMING_SNAKE_CASE__    							=   None

     if text_encoding is not None:
       encoding_image_processor.update(_lowercase   )

     return encoding_image_processor




   def 			__a		(					self    :       str ,			*_lowercase    :       Optional[int] ,			**_lowercase    :       Tuple   ):



     """simple docstring"""






     return self.tokenizer.batch_decode(*_lowercase ,			**_lowercase   )




   def 			__a		(					self    :       Any ,			*_lowercase    :       int ,			**_lowercase    :       str   ):



     """simple docstring"""






     return self.tokenizer.decode(*_lowercase ,			**_lowercase   )




   @property
   def 			__a		(					self    :       Optional[Any]   ):



     """simple docstring"""






     SCREAMING_SNAKE_CASE__    							=   self.tokenizer.model_input_names
     SCREAMING_SNAKE_CASE__    							=   self.image_processor.model_input_names
     return list(dict.fromkeys(tokenizer_input_names + image_processor_input_names   )   )

# coding=utf-8
# Copyright 2020 The HuggingFace Inc. team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# this script dumps information about the environment

import os
import sys

import transformers


__lowerCamelCase    :				Tuple							     =	'''3'''

print('''Python version:''', sys.version)
print('''transformers version:''', transformers.__version__)

try:
   import torch

   print('''Torch version:''', torch.__version__)
   print('''Cuda available:''', torch.cuda.is_available())
   print('''Cuda version:''', torch.version.cuda)
   print('''CuDNN version:''', torch.backends.cudnn.version())
   print('''Number of GPUs available:''', torch.cuda.device_count())
   print('''NCCL version:''', torch.cuda.nccl.version())
except ImportError:
   print('''Torch version:''', None)

try:
   import deepspeed

   print('''DeepSpeed version:''', deepspeed.__version__)
except ImportError:
   print('''DeepSpeed version:''', None)

try:
   import tensorflow as tf

   print('''TensorFlow version:''', tf.__version__)
   print('''TF GPUs available:''', bool(tf.config.list_physical_devices('''GPU''')))
   print('''Number of TF GPUs available:''', len(tf.config.list_physical_devices('''GPU''')))
except ImportError:
   print('''TensorFlow version:''', None)
