

import copy
import os
from typing import Union

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


SCREAMING_SNAKE_CASE_        =      logging.get_logger(__name__)

SCREAMING_SNAKE_CASE_        =      {
    'microsoft/git-base': 'https://huggingface.co/microsoft/git-base/resolve/main/config.json',
}

class 				a  (	UpperCAmelCase				):
						_lowercase    						=			"git_vision_model"


						def __init__(       self						,					A_=768						,					A_=3072						,					A_=12						,					A_=12						,					A_=3						,					A_=224						,					A_=16						,					A_="quick_gelu"						,					A_=1e-5						,					A_=0.0						,					A_=0.02						,					**A_						,					):







										'''simple docstring'''


										super().__init__(**A_	)

										_UpperCAmelCase       :		Union[str, Any] 		=    hidden_size
										_UpperCAmelCase       :		Tuple 		=    intermediate_size
										_UpperCAmelCase       :		int 		=    num_hidden_layers
										_UpperCAmelCase       :		str 		=    num_attention_heads
										_UpperCAmelCase       :		str 		=    num_channels
										_UpperCAmelCase       :		Any 		=    patch_size
										_UpperCAmelCase       :		Any 		=    image_size
										_UpperCAmelCase       :		Optional[Any] 		=    initializer_range
										_UpperCAmelCase       :		Optional[Any] 		=    attention_dropout
										_UpperCAmelCase       :		Optional[Any] 		=    layer_norm_eps
										_UpperCAmelCase       :		Dict 		=    hidden_act





						@classmethod
						def        _UpperCAmelCase				(       cls						,					A_						,					**A_	):







										'''simple docstring'''


										cls._set_token_in_kwargs(A_	)

										_UpperCAmelCase       :		Dict 		=    cls.get_config_dict(A_						,					**A_	)

										# get the vision config dict if we are loading from GITConfig
										if config_dict.get("model_type"	) == "git":
														_UpperCAmelCase       :		List[Any] 		=    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(A_						,					**A_	)







class 				a  (	UpperCAmelCase				):
						_lowercase    						=			"git"


						def __init__(       self						,					A_=None						,					A_=30522						,					A_=768						,					A_=6						,					A_=12						,					A_=3072						,					A_="gelu"						,					A_=0.1						,					A_=0.1						,					A_=1024						,					A_=0.02						,					A_=1e-12						,					A_=0						,					A_="absolute"						,					A_=True						,					A_=False						,					A_=101						,					A_=102						,					A_=None						,					**A_						,					):







										'''simple docstring'''


										super().__init__(bos_token_id=A_						,					eos_token_id=A_						,					pad_token_id=A_						,					**A_	)

										if vision_config is None:
														_UpperCAmelCase       :		Any 		=    {}
														logger.info("vision_config is None. initializing the GitVisionConfig with default values."	)

										_UpperCAmelCase       :		str 		=    GitVisionConfig(**A_	)
										_UpperCAmelCase       :		Any 		=    vocab_size
										_UpperCAmelCase       :		List[Any] 		=    hidden_size
										_UpperCAmelCase       :		List[str] 		=    num_hidden_layers
										_UpperCAmelCase       :		Optional[Any] 		=    num_attention_heads
										_UpperCAmelCase       :		Tuple 		=    hidden_act
										_UpperCAmelCase       :		List[Any] 		=    intermediate_size
										_UpperCAmelCase       :		int 		=    hidden_dropout_prob
										_UpperCAmelCase       :		str 		=    attention_probs_dropout_prob
										_UpperCAmelCase       :		Tuple 		=    max_position_embeddings
										_UpperCAmelCase       :		Union[str, Any] 		=    initializer_range
										_UpperCAmelCase       :		Tuple 		=    layer_norm_eps
										_UpperCAmelCase       :		Dict 		=    position_embedding_type
										_UpperCAmelCase       :		Any 		=    use_cache
										_UpperCAmelCase       :		Optional[int] 		=    tie_word_embeddings
										_UpperCAmelCase       :		List[str] 		=    num_image_with_embedding

										_UpperCAmelCase       :		Optional[int] 		=    bos_token_id
										_UpperCAmelCase       :		List[Any] 		=    eos_token_id





						def        _UpperCAmelCase				(       self	):







										'''simple docstring'''


										_UpperCAmelCase       :		List[str] 		=    copy.deepcopy(self.__dict__	)
										_UpperCAmelCase       :		Union[str, Any] 		=    self.vision_config.to_dict()
										_UpperCAmelCase       :		Union[str, Any] 		=    self.__class__.model_type
										return output





import unittest

from transformers import load_tool

from .test_tools_common import ToolTesterMixin


SCREAMING_SNAKE_CASE_        =      '\nHugging Face was founded in 2016 by French entrepreneurs Clément Delangue, Julien Chaumond, and Thomas Wolf originally as a company that developed a chatbot app targeted at teenagers.[2] After open-sourcing the model behind the chatbot, the company pivoted to focus on being a platform for machine learning.\n\nIn March 2021, Hugging Face raised $40 million in a Series B funding round.[3]\n\nOn April 28, 2021, the company launched the BigScience Research Workshop in collaboration with several other research groups to release an open large language model.[4] In 2022, the workshop concluded with the announcement of BLOOM, a multilingual large language model with 176 billion parameters.[5]\n'

class 				a  (	unittest.TestCase							, UpperCAmelCase				):


						def        _UpperCAmelCase				(       self	):







										'''simple docstring'''


										_UpperCAmelCase       :		Tuple 		=    load_tool("text-question-answering"	)
										self.tool.setup()
										_UpperCAmelCase       :		str 		=    load_tool("text-question-answering"						,					remote=A_	)


						def        _UpperCAmelCase				(       self	):







										'''simple docstring'''


										_UpperCAmelCase       :		List[str] 		=    self.tool(A_						,					"What did Hugging Face do in April 2021?"	)
										self.assertEqual(A_						,					"launched the BigScience Research Workshop"	)


						def        _UpperCAmelCase				(       self	):







										'''simple docstring'''


										_UpperCAmelCase       :		Optional[Any] 		=    self.remote_tool(A_						,					"What did Hugging Face do in April 2021?"	)
										self.assertEqual(A_						,					"launched the BigScience Research Workshop"	)


						def        _UpperCAmelCase				(       self	):







										'''simple docstring'''


										_UpperCAmelCase       :		int 		=    self.tool(text=A_						,					question="What did Hugging Face do in April 2021?"	)
										self.assertEqual(A_						,					"launched the BigScience Research Workshop"	)





						def        _UpperCAmelCase				(       self	):







										'''simple docstring'''


										_UpperCAmelCase       :		List[Any] 		=    self.remote_tool(text=A_						,					question="What did Hugging Face do in April 2021?"	)
										self.assertEqual(A_						,					"launched the BigScience Research Workshop"	)


