






"""simple docstring"""
import copy
import os
from typing import Union

from ...configuration_utils import PretrainedConfig
from ...utils import logging


lowerCAmelCase__    						=			logging.get_logger(__name__)

lowerCAmelCase__    						=			{
    'Salesforce/blip-vqa-base': 'https://huggingface.co/Salesforce/blip-vqa-base/resolve/main/config.json',
    'Salesforce/blip-vqa-capfit-large': (
        'https://huggingface.co/Salesforce/blip-vqa-base-capfit/resolve/main/config.json'
    ),
    'Salesforce/blip-image-captioning-base': (
        'https://huggingface.co/Salesforce/blip-image-captioning-base/resolve/main/config.json'
    ),
    'Salesforce/blip-image-captioning-large': (
        'https://huggingface.co/Salesforce/blip-image-captioning-large/resolve/main/config.json'
    ),
    'Salesforce/blip-itm-base-coco': 'https://huggingface.co/Salesforce/blip-itm-base-coco/resolve/main/config.json',
    'Salesforce/blip-itm-large-coco': 'https://huggingface.co/Salesforce/blip-itm-large-coco/resolve/main/config.json',
    'Salesforce/blip-itm-base-flikr': 'https://huggingface.co/Salesforce/blip-itm-base-flikr/resolve/main/config.json',
    'Salesforce/blip-itm-large-flikr': (
        'https://huggingface.co/Salesforce/blip-itm-large-flikr/resolve/main/config.json'
    ),
}


class _lowerCAmelCase						(    __UpperCAmelCase       ):
						SCREAMING_SNAKE_CASE_:					Tuple 					=				'blip_text_model'







						def __init__(    self   ,				lowerCAmelCase_=3_0_5_2_4   ,				lowerCAmelCase_=7_6_8   ,				lowerCAmelCase_=7_6_8   ,				lowerCAmelCase_=3_0_7_2   ,				lowerCAmelCase_=7_6_8   ,				lowerCAmelCase_=1_2   ,				lowerCAmelCase_=8   ,				lowerCAmelCase_=5_1_2   ,				lowerCAmelCase_="gelu"   ,				lowerCAmelCase_=1e-12   ,				lowerCAmelCase_=0.0   ,				lowerCAmelCase_=0.0   ,				lowerCAmelCase_=0.02   ,				lowerCAmelCase_=3_0_5_2_2   ,				lowerCAmelCase_=2   ,				lowerCAmelCase_=0   ,				lowerCAmelCase_=1_0_2   ,				lowerCAmelCase_=True   ,				lowerCAmelCase_=True   ,				**lowerCAmelCase_   ,				)		->							Union[str, Any]:
										super().__init__(
										    pad_token_id=lowerCAmelCase_   ,				bos_token_id=lowerCAmelCase_   ,				eos_token_id=lowerCAmelCase_   ,				sep_token_id=lowerCAmelCase_   ,				**lowerCAmelCase_   ,				)

										_SCREAMING_SNAKE_CASE   :		Dict       		=    vocab_size
										_SCREAMING_SNAKE_CASE   :		Dict       		=    hidden_size
										_SCREAMING_SNAKE_CASE   :		Tuple       		=    encoder_hidden_size
										_SCREAMING_SNAKE_CASE   :		Tuple       		=    intermediate_size
										_SCREAMING_SNAKE_CASE   :		Dict       		=    projection_dim
										_SCREAMING_SNAKE_CASE   :		Optional[int]       		=    hidden_dropout_prob
										_SCREAMING_SNAKE_CASE   :		Tuple       		=    num_hidden_layers
										_SCREAMING_SNAKE_CASE   :		List[Any]       		=    num_attention_heads
										_SCREAMING_SNAKE_CASE   :		str       		=    max_position_embeddings
										_SCREAMING_SNAKE_CASE   :		List[str]       		=    layer_norm_eps
										_SCREAMING_SNAKE_CASE   :		List[str]       		=    hidden_act
										_SCREAMING_SNAKE_CASE   :		List[str]       		=    initializer_range
										_SCREAMING_SNAKE_CASE   :		int       		=    attention_probs_dropout_prob
										_SCREAMING_SNAKE_CASE   :		Optional[Any]       		=    is_decoder
										_SCREAMING_SNAKE_CASE   :		Optional[int]       		=    use_cache







						@classmethod
						def 			A      (    cls   ,				lowerCAmelCase_   ,				**lowerCAmelCase_							)		->							"PretrainedConfig":
										cls._set_token_in_kwargs(lowerCAmelCase_							)

										_SCREAMING_SNAKE_CASE		,						_SCREAMING_SNAKE_CASE   :		List[Any]       		=    cls.get_config_dict(lowerCAmelCase_   ,				**lowerCAmelCase_							)

										# get the text config dict if we are loading from BlipConfig
										if config_dict.get('model_type'							) == "blip":
														_SCREAMING_SNAKE_CASE   :		Tuple       		=    config_dict['text_config']

										if "model_type" in config_dict and hasattr(cls   ,				'model_type'							) and config_dict["model_type"] != cls.model_type:
														logger.warning(
														    F"""You are using a model of type {config_dict["model_type"]} to instantiate a model of type """
														    F"""{cls.model_type}. This is not supported for all configurations of models and can yield errors."""							)

										return cls.from_dict(lowerCAmelCase_   ,				**lowerCAmelCase_							)







class _lowerCAmelCase						(    __UpperCAmelCase       ):
						SCREAMING_SNAKE_CASE_:					int 					=				'blip_vision_model'







						def __init__(    self   ,				lowerCAmelCase_=7_6_8   ,				lowerCAmelCase_=3_0_7_2   ,				lowerCAmelCase_=5_1_2   ,				lowerCAmelCase_=1_2   ,				lowerCAmelCase_=1_2   ,				lowerCAmelCase_=3_8_4   ,				lowerCAmelCase_=1_6   ,				lowerCAmelCase_="gelu"   ,				lowerCAmelCase_=1e-5   ,				lowerCAmelCase_=0.0   ,				lowerCAmelCase_=1e-10   ,				**lowerCAmelCase_   ,				)		->							List[str]:
										super().__init__(**lowerCAmelCase_							)

										_SCREAMING_SNAKE_CASE   :		List[Any]       		=    hidden_size
										_SCREAMING_SNAKE_CASE   :		str       		=    intermediate_size
										_SCREAMING_SNAKE_CASE   :		int       		=    projection_dim
										_SCREAMING_SNAKE_CASE   :		List[Any]       		=    num_hidden_layers
										_SCREAMING_SNAKE_CASE   :		Any       		=    num_attention_heads
										_SCREAMING_SNAKE_CASE   :		Optional[int]       		=    patch_size
										_SCREAMING_SNAKE_CASE   :		Union[str, Any]       		=    image_size
										_SCREAMING_SNAKE_CASE   :		Dict       		=    initializer_range
										_SCREAMING_SNAKE_CASE   :		Union[str, Any]       		=    attention_dropout
										_SCREAMING_SNAKE_CASE   :		int       		=    layer_norm_eps
										_SCREAMING_SNAKE_CASE   :		Optional[int]       		=    hidden_act







						@classmethod
						def 			A      (    cls   ,				lowerCAmelCase_   ,				**lowerCAmelCase_							)		->							"PretrainedConfig":
										cls._set_token_in_kwargs(lowerCAmelCase_							)

										_SCREAMING_SNAKE_CASE		,						_SCREAMING_SNAKE_CASE   :		List[str]       		=    cls.get_config_dict(lowerCAmelCase_   ,				**lowerCAmelCase_							)

										# get the vision config dict if we are loading from BlipConfig
										if config_dict.get('model_type'							) == "blip":
														_SCREAMING_SNAKE_CASE   :		Tuple       		=    config_dict['vision_config']

										if "model_type" in config_dict and hasattr(cls   ,				'model_type'							) and config_dict["model_type"] != cls.model_type:
														logger.warning(
														    F"""You are using a model of type {config_dict["model_type"]} to instantiate a model of type """
														    F"""{cls.model_type}. This is not supported for all configurations of models and can yield errors."""							)

										return cls.from_dict(lowerCAmelCase_   ,				**lowerCAmelCase_							)







class _lowerCAmelCase						(    __UpperCAmelCase       ):
						SCREAMING_SNAKE_CASE_:					str 					=				'blip'
						SCREAMING_SNAKE_CASE_:					Optional[int] 					=				True







						def __init__(    self   ,				lowerCAmelCase_=None   ,				lowerCAmelCase_=None   ,				lowerCAmelCase_=5_1_2   ,				lowerCAmelCase_=2.6_592   ,				lowerCAmelCase_=2_5_6   ,				**lowerCAmelCase_   ,				)		->							Dict:
										super().__init__(**lowerCAmelCase_							)

										if text_config is None:
														_SCREAMING_SNAKE_CASE   :		List[str]       		=    {}
														logger.info('`text_config` is `None`. Initializing the `BlipTextConfig` with default values.'							)

										if vision_config is None:
														_SCREAMING_SNAKE_CASE   :		Tuple       		=    {}
														logger.info('`vision_config` is `None`. Initializing the `BlipVisionConfig` with default values.'							)

										_SCREAMING_SNAKE_CASE   :		Optional[Any]       		=    BlipTextConfig(**lowerCAmelCase_							)
										_SCREAMING_SNAKE_CASE   :		Any       		=    BlipVisionConfig(**lowerCAmelCase_							)

										_SCREAMING_SNAKE_CASE   :		Union[str, Any]       		=    self.vision_config.hidden_size

										_SCREAMING_SNAKE_CASE   :		Optional[Any]       		=    projection_dim
										_SCREAMING_SNAKE_CASE   :		Union[str, Any]       		=    logit_scale_init_value
										_SCREAMING_SNAKE_CASE   :		Optional[Any]       		=    1.0
										_SCREAMING_SNAKE_CASE   :		Union[str, Any]       		=    0.02
										_SCREAMING_SNAKE_CASE   :		Tuple       		=    image_text_hidden_size







						@classmethod
						def 			A      (    cls   ,				lowerCAmelCase_   ,				lowerCAmelCase_   ,				**lowerCAmelCase_							)		->							List[Any]:
										return cls(text_config=text_config.to_dict()   ,				vision_config=vision_config.to_dict()   ,				**lowerCAmelCase_							)







						def 			A      (    self							)		->							Optional[int]:
										_SCREAMING_SNAKE_CASE   :		List[Any]       		=    copy.deepcopy(self.__dict__							)
										_SCREAMING_SNAKE_CASE   :		Optional[int]       		=    self.text_config.to_dict()
										_SCREAMING_SNAKE_CASE   :		str       		=    self.vision_config.to_dict()
										_SCREAMING_SNAKE_CASE   :		Optional[int]       		=    self.__class__.model_type
										return output









"""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"

