






"""simple docstring"""
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 _lowerCAmelCase						(    __UpperCAmelCase       ):
						SCREAMING_SNAKE_CASE_:					Tuple 					=				['image_processor', 'tokenizer']
						SCREAMING_SNAKE_CASE_:					Tuple 					=				'BlipImageProcessor'
						SCREAMING_SNAKE_CASE_:					Union[str, Any] 					=				('BertTokenizer', 'BertTokenizerFast')







						def __init__(    self   ,				lowerCAmelCase_   ,				lowerCAmelCase_							)		->							Dict:
										_SCREAMING_SNAKE_CASE   :		List[str]       		=    False
										super().__init__(lowerCAmelCase_   ,				lowerCAmelCase_							)
										_SCREAMING_SNAKE_CASE   :		List[Any]       		=    self.image_processor







						def __call__(    self   ,				lowerCAmelCase_ = None   ,				lowerCAmelCase_ = None   ,				lowerCAmelCase_ = True   ,				lowerCAmelCase_ = False   ,				lowerCAmelCase_ = None   ,				lowerCAmelCase_ = None   ,				lowerCAmelCase_ = 0   ,				lowerCAmelCase_ = None   ,				lowerCAmelCase_ = None   ,				lowerCAmelCase_ = False   ,				lowerCAmelCase_ = False   ,				lowerCAmelCase_ = False   ,				lowerCAmelCase_ = False   ,				lowerCAmelCase_ = False   ,				lowerCAmelCase_ = True   ,				lowerCAmelCase_ = None   ,				**lowerCAmelCase_   ,				)		->							BatchEncoding:
										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   :		str       		=    self.tokenizer
														_SCREAMING_SNAKE_CASE   :		str       		=    self.tokenizer(
														    text=lowerCAmelCase_   ,				add_special_tokens=lowerCAmelCase_   ,				padding=lowerCAmelCase_   ,				truncation=lowerCAmelCase_   ,				max_length=lowerCAmelCase_   ,				stride=lowerCAmelCase_   ,				pad_to_multiple_of=lowerCAmelCase_   ,				return_attention_mask=lowerCAmelCase_   ,				return_overflowing_tokens=lowerCAmelCase_   ,				return_special_tokens_mask=lowerCAmelCase_   ,				return_offsets_mapping=lowerCAmelCase_   ,				return_token_type_ids=lowerCAmelCase_   ,				return_length=lowerCAmelCase_   ,				verbose=lowerCAmelCase_   ,				return_tensors=lowerCAmelCase_   ,				**lowerCAmelCase_   ,				)
														return text_encoding

										# add pixel_values
										_SCREAMING_SNAKE_CASE   :		int       		=    self.image_processor(lowerCAmelCase_   ,				return_tensors=lowerCAmelCase_							)

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

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

										return encoding_image_processor







						def 			A      (    self   ,				*lowerCAmelCase_   ,				**lowerCAmelCase_							)		->							Dict:
										return self.tokenizer.batch_decode(*lowerCAmelCase_   ,				**lowerCAmelCase_							)







						def 			A      (    self   ,				*lowerCAmelCase_   ,				**lowerCAmelCase_							)		->							Any:
										return self.tokenizer.decode(*lowerCAmelCase_   ,				**lowerCAmelCase_							)







						@property
						def 			A      (    self							)		->							Optional[Any]:
										_SCREAMING_SNAKE_CASE   :		Union[str, Any]       		=    self.tokenizer.model_input_names
										_SCREAMING_SNAKE_CASE   :		Any       		=    self.image_processor.model_input_names
										return list(dict.fromkeys(tokenizer_input_names + image_processor_input_names							)							)









"""simple docstring"""
import platform
from argparse import ArgumentParser

import huggingface_hub

from .. import __version__ as version
from ..utils import is_accelerate_available, is_torch_available, is_transformers_available, is_xformers_available
from . import BaseDiffusersCLICommand





def 				lowercase__		(					lowerCamelCase       ):
				return EnvironmentCommand()






class _lowerCAmelCase						(    __UpperCAmelCase       ):







						@staticmethod
						def 			A      (    lowerCAmelCase_							)		->							List[Any]:
										_SCREAMING_SNAKE_CASE   :		int       		=    parser.add_parser('env'							)
										download_parser.set_defaults(func=lowerCAmelCase_							)







						def 			A      (    self							)		->							Any:
										_SCREAMING_SNAKE_CASE   :		int       		=    huggingface_hub.__version__

										_SCREAMING_SNAKE_CASE   :		Optional[Any]       		=    'not installed'
										_SCREAMING_SNAKE_CASE   :		Union[str, Any]       		=    'NA'
										if is_torch_available():
														import torch

														_SCREAMING_SNAKE_CASE   :		Union[str, Any]       		=    torch.__version__
														_SCREAMING_SNAKE_CASE   :		Union[str, Any]       		=    torch.cuda.is_available()

										_SCREAMING_SNAKE_CASE   :		Union[str, Any]       		=    'not installed'
										if is_transformers_available():
														import transformers

														_SCREAMING_SNAKE_CASE   :		Tuple       		=    transformers.__version__

										_SCREAMING_SNAKE_CASE   :		Optional[int]       		=    'not installed'
										if is_accelerate_available():
														import accelerate

														_SCREAMING_SNAKE_CASE   :		str       		=    accelerate.__version__

										_SCREAMING_SNAKE_CASE   :		str       		=    'not installed'
										if is_xformers_available():
														import xformers

														_SCREAMING_SNAKE_CASE   :		Optional[int]       		=    xformers.__version__

										_SCREAMING_SNAKE_CASE   :		Any       		=    {
										    '`diffusers` version': version,
										    'Platform': platform.platform(),
										    'Python version': platform.python_version(),
										    'PyTorch version (GPU?)': F"""{pt_version} ({pt_cuda_available})""",
										    'Huggingface_hub version': hub_version,
										    'Transformers version': transformers_version,
										    'Accelerate version': accelerate_version,
										    'xFormers version': xformers_version,
										    'Using GPU in script?': '<fill in>',
										    'Using distributed or parallel set-up in script?': '<fill in>',
										}

										print('\nCopy-and-paste the text below in your GitHub issue and FILL OUT the two last points.\n'							)
										print(self.format_dict(lowerCAmelCase_							)							)

										return info







						@staticmethod
						def 			A      (    lowerCAmelCase_							)		->							int:
										return "\n".join([F"""- {prop}: {val}""" for prop, val in d.items()]							) + "\n"

