



"""simple docstring"""







import unittest

from transformers import load_tool

from .test_tools_common import ToolTesterMixin


lowercase__		:    Dict				   =     """
Hugging 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.

In March 2021, Hugging Face raised $40 million in a Series B funding round.[3]

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







class 				UpperCamelCase__       (     unittest.TestCase, lowercase_  ):




      """simple docstring"""




      def 					SCREAMING_SNAKE_CASE__			(				self    :				Optional[int]	):
        lowerCAmelCase_       :    List[str]								=			load_tool('text-question-answering'	)
        self.tool.setup()
        lowerCAmelCase_       :    Dict								=			load_tool('text-question-answering'   ,      remote=SCREAMING_SNAKE_CASE_	)



      def 					SCREAMING_SNAKE_CASE__			(				self    :				int	):
        lowerCAmelCase_       :    List[str]								=			self.tool(SCREAMING_SNAKE_CASE_   ,      'What did Hugging Face do in April 2021?'	)
        self.assertEqual(SCREAMING_SNAKE_CASE_   ,      'launched the BigScience Research Workshop'	)



      def 					SCREAMING_SNAKE_CASE__			(				self    :				Dict	):
        lowerCAmelCase_       :    List[Any]								=			self.remote_tool(SCREAMING_SNAKE_CASE_   ,      'What did Hugging Face do in April 2021?'	)
        self.assertEqual(SCREAMING_SNAKE_CASE_   ,      'launched the BigScience Research Workshop'	)



      def 					SCREAMING_SNAKE_CASE__			(				self    :				Tuple	):
        lowerCAmelCase_       :    Any								=			self.tool(text=SCREAMING_SNAKE_CASE_   ,      question='What did Hugging Face do in April 2021?'	)
        self.assertEqual(SCREAMING_SNAKE_CASE_   ,      'launched the BigScience Research Workshop'	)





      def 					SCREAMING_SNAKE_CASE__			(				self    :				Tuple	):
        lowerCAmelCase_       :    Tuple								=			self.remote_tool(text=SCREAMING_SNAKE_CASE_   ,      question='What did Hugging Face do in April 2021?'	)
        self.assertEqual(SCREAMING_SNAKE_CASE_   ,      'launched the BigScience Research Workshop'	)










"""simple docstring"""







from ...configuration_utils import PretrainedConfig
from ...utils import logging
from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices


lowercase__		:    Optional[int]				   =     logging.get_logger(__name__)







class 				UpperCamelCase__       (     lowercase_, lowercase_  ):




      """simple docstring"""




      _SCREAMING_SNAKE_CASE      =					"""maskformer-swin"""

      _SCREAMING_SNAKE_CASE      =					{
          """num_attention_heads""": """num_heads""",
          """num_hidden_layers""": """num_layers""",
      }



      def __init__(				self    :				Tuple   ,      SCREAMING_SNAKE_CASE_    :				Optional[Any]=2_2_4   ,      SCREAMING_SNAKE_CASE_    :				Union[str, Any]=4   ,      SCREAMING_SNAKE_CASE_    :				int=3   ,      SCREAMING_SNAKE_CASE_    :				Dict=9_6   ,      SCREAMING_SNAKE_CASE_    :				Optional[int]=[2, 2, 6, 2]   ,      SCREAMING_SNAKE_CASE_    :				List[Any]=[3, 6, 1_2, 2_4]   ,      SCREAMING_SNAKE_CASE_    :				List[str]=7   ,      SCREAMING_SNAKE_CASE_    :				Union[str, Any]=4.0   ,      SCREAMING_SNAKE_CASE_    :				Optional[Any]=True   ,      SCREAMING_SNAKE_CASE_    :				Tuple=0.0   ,      SCREAMING_SNAKE_CASE_    :				Union[str, Any]=0.0   ,      SCREAMING_SNAKE_CASE_    :				int=0.1   ,      SCREAMING_SNAKE_CASE_    :				Union[str, Any]="gelu"   ,      SCREAMING_SNAKE_CASE_    :				Dict=False   ,      SCREAMING_SNAKE_CASE_    :				Union[str, Any]=0.02   ,      SCREAMING_SNAKE_CASE_    :				int=1E-5   ,      SCREAMING_SNAKE_CASE_    :				Dict=None   ,      SCREAMING_SNAKE_CASE_    :				Optional[int]=None   ,      **SCREAMING_SNAKE_CASE_    :				str   ,      ):
        super().__init__(**SCREAMING_SNAKE_CASE_	)

        lowerCAmelCase_       :    Dict								=			image_size
        lowerCAmelCase_       :    Optional[Any]								=			patch_size
        lowerCAmelCase_       :    Optional[int]								=			num_channels
        lowerCAmelCase_       :    List[str]								=			embed_dim
        lowerCAmelCase_       :    Dict								=			depths
        lowerCAmelCase_       :    Optional[Any]								=			len(SCREAMING_SNAKE_CASE_	)
        lowerCAmelCase_       :    Tuple								=			num_heads
        lowerCAmelCase_       :    List[str]								=			window_size
        lowerCAmelCase_       :    Any								=			mlp_ratio
        lowerCAmelCase_       :    Any								=			qkv_bias
        lowerCAmelCase_       :    List[Any]								=			hidden_dropout_prob
        lowerCAmelCase_       :    List[Any]								=			attention_probs_dropout_prob
        lowerCAmelCase_       :    Tuple								=			drop_path_rate
        lowerCAmelCase_       :    List[str]								=			hidden_act
        lowerCAmelCase_       :    Any								=			use_absolute_embeddings
        lowerCAmelCase_       :    Optional[Any]								=			layer_norm_eps
        lowerCAmelCase_       :    str								=			initializer_range
        # we set the hidden_size attribute in order to make Swin work with VisionEncoderDecoderModel
        # this indicates the channel dimension after the last stage of the model
        lowerCAmelCase_       :    List[str]								=			int(embed_dim * 2 ** (len(SCREAMING_SNAKE_CASE_	) - 1)	)
        lowerCAmelCase_       :    List[Any]								=			['stem'] + [F"stage{idx}" for idx in range(1   ,      len(SCREAMING_SNAKE_CASE_	) + 1	)]
        lowerCAmelCase_						,lowerCAmelCase_       :    Tuple								=			get_aligned_output_features_output_indices(
            out_features=SCREAMING_SNAKE_CASE_   ,      out_indices=SCREAMING_SNAKE_CASE_   ,      stage_names=self.stage_names	)





