
"""simple docstring"""

# 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


SCREAMING_SNAKE_CASE_            =    '''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)





"""simple docstring"""

from ...processing_utils import ProcessorMixin
from ...tokenization_utils_base import BatchEncoding
class   _UpperCAmelCase				(		SCREAMING_SNAKE_CASE_				):
      __SCREAMING_SNAKE_CASE :				List[Any]				   =						["image_processor", "tokenizer"]
      __SCREAMING_SNAKE_CASE :				Dict				   =						"AutoImageProcessor"
      __SCREAMING_SNAKE_CASE :				Optional[int]				   =						"AutoTokenizer"




      def __init__(				self ,							lowercase_ ,							lowercase_				)    ->       List[str]:
          super().__init__(lowercase_ ,							lowercase_				)
          UpperCAmelCase          =       self.image_processor




      def __call__(				self ,							lowercase_=None ,							lowercase_=None ,							lowercase_=None ,							**lowercase_				)    ->       Any:

          if text is None and images is None:
              raise ValueError('You have to specify either text or images. Both cannot be none.'				)

          if text is not None:
              UpperCAmelCase          =       self.tokenizer(lowercase_ ,							return_tensors=lowercase_ ,							**lowercase_				)

          if images is not None:
              UpperCAmelCase          =       self.image_processor(lowercase_ ,							return_tensors=lowercase_ ,							**lowercase_				)

          if text is not None and images is not None:
              UpperCAmelCase          =       image_features.pixel_values
              return encoding
          elif text is not None:
              return encoding
          else:
              return BatchEncoding(data=dict(**lowercase_				) ,							tensor_type=lowercase_				)




      def      a_   (				self ,							*lowercase_ ,							**lowercase_				)    ->       Optional[Any]:
          return self.tokenizer.batch_decode(*lowercase_ ,							**lowercase_				)




      def      a_   (				self ,							*lowercase_ ,							**lowercase_				)    ->       Optional[int]:
          return self.tokenizer.decode(*lowercase_ ,							**lowercase_				)




      @property
      def      a_   (				self				)    ->       Optional[int]:
          return ["input_ids", "attention_mask", "pixel_values"]



