

import copy

from ...configuration_utils import PretrainedConfig
from ...utils import logging
from ..auto import CONFIG_MAPPING


UpperCamelCase__  :      str			=    logging.get_logger(__name__)

UpperCamelCase__  :      str			=    {
    "ut/deta": "https://huggingface.co/ut/deta/resolve/main/config.json",
}



class       __snake_case  (    lowerCAmelCase__       ):
  __lowerCAmelCase     :	Union[str, Any]						 =  'deta'
  __lowerCAmelCase     :	Optional[Any]						 =  {
      'hidden_size': 'd_model',
      'num_attention_heads': 'encoder_attention_heads',
  }

  def __init__(					self						,		_A=None						,		_A=900						,		_A=2048						,		_A=6						,		_A=2048						,		_A=8						,		_A=6						,		_A=1024						,		_A=8						,		_A=0.0						,		_A=True						,		_A="relu"						,		_A=256						,		_A=0.1						,		_A=0.0						,		_A=0.0						,		_A=0.0_2						,		_A=1.0						,		_A=True						,		_A=False						,		_A="sine"						,		_A=5						,		_A=4						,		_A=4						,		_A=True						,		_A=300						,		_A=True						,		_A=True						,		_A=1						,		_A=5						,		_A=2						,		_A=1						,		_A=1						,		_A=5						,		_A=2						,		_A=0.1						,		_A=0.2_5						,		**_A						,		):
      if backbone_config is None:
          logger.info('`backbone_config` is `None`. Initializing the config with the default `ResNet` backbone.')
          SCREAMING_SNAKE_CASE_									=						CONFIG_MAPPING['resnet'](out_features=['stage2', 'stage3', 'stage4'])
      else:
          if isinstance(_A						,		_A):
              SCREAMING_SNAKE_CASE_									=						backbone_config.pop('model_type')
              SCREAMING_SNAKE_CASE_									=						CONFIG_MAPPING[backbone_model_type]
              SCREAMING_SNAKE_CASE_									=						config_class.from_dict(_A)

      SCREAMING_SNAKE_CASE_									=						backbone_config
      SCREAMING_SNAKE_CASE_									=						num_queries
      SCREAMING_SNAKE_CASE_									=						max_position_embeddings
      SCREAMING_SNAKE_CASE_									=						d_model
      SCREAMING_SNAKE_CASE_									=						encoder_ffn_dim
      SCREAMING_SNAKE_CASE_									=						encoder_layers
      SCREAMING_SNAKE_CASE_									=						encoder_attention_heads
      SCREAMING_SNAKE_CASE_									=						decoder_ffn_dim
      SCREAMING_SNAKE_CASE_									=						decoder_layers
      SCREAMING_SNAKE_CASE_									=						decoder_attention_heads
      SCREAMING_SNAKE_CASE_									=						dropout
      SCREAMING_SNAKE_CASE_									=						attention_dropout
      SCREAMING_SNAKE_CASE_									=						activation_dropout
      SCREAMING_SNAKE_CASE_									=						activation_function
      SCREAMING_SNAKE_CASE_									=						init_std
      SCREAMING_SNAKE_CASE_									=						init_xavier_std
      SCREAMING_SNAKE_CASE_									=						encoder_layerdrop
      SCREAMING_SNAKE_CASE_									=						auxiliary_loss
      SCREAMING_SNAKE_CASE_									=						position_embedding_type
      # deformable attributes
      SCREAMING_SNAKE_CASE_									=						num_feature_levels
      SCREAMING_SNAKE_CASE_									=						encoder_n_points
      SCREAMING_SNAKE_CASE_									=						decoder_n_points
      SCREAMING_SNAKE_CASE_									=						two_stage
      SCREAMING_SNAKE_CASE_									=						two_stage_num_proposals
      SCREAMING_SNAKE_CASE_									=						with_box_refine
      SCREAMING_SNAKE_CASE_									=						assign_first_stage
      if two_stage is True and with_box_refine is False:
          raise ValueError('If two_stage is True, with_box_refine must be True.')
      # Hungarian matcher
      SCREAMING_SNAKE_CASE_									=						class_cost
      SCREAMING_SNAKE_CASE_									=						bbox_cost
      SCREAMING_SNAKE_CASE_									=						giou_cost
      # Loss coefficients
      SCREAMING_SNAKE_CASE_									=						mask_loss_coefficient
      SCREAMING_SNAKE_CASE_									=						dice_loss_coefficient
      SCREAMING_SNAKE_CASE_									=						bbox_loss_coefficient
      SCREAMING_SNAKE_CASE_									=						giou_loss_coefficient
      SCREAMING_SNAKE_CASE_									=						eos_coefficient
      SCREAMING_SNAKE_CASE_									=						focal_alpha
      super().__init__(is_encoder_decoder=_A						,		**_A)

  @property
  def 						lowerCAmelCase__     (					self):
      return self.encoder_attention_heads

  @property
  def 						lowerCAmelCase__     (					self):
      return self.d_model


  def 						lowerCAmelCase__     (					self):
      SCREAMING_SNAKE_CASE_									=						copy.deepcopy(self.__dict__)
      SCREAMING_SNAKE_CASE_									=						self.backbone_config.to_dict()
      SCREAMING_SNAKE_CASE_									=						self.__class__.model_type
      return output





import unittest

from transformers import load_tool

from .test_tools_common import ToolTesterMixin


UpperCamelCase__  :      int			=    "\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       __snake_case  (    unittest.TestCase     , lowerCAmelCase__       ):

  def 						lowerCAmelCase__     (					self):
      SCREAMING_SNAKE_CASE_									=						load_tool('text-question-answering')
      self.tool.setup()
      SCREAMING_SNAKE_CASE_									=						load_tool('text-question-answering'						,		remote=_A)

  def 						lowerCAmelCase__     (					self):
      SCREAMING_SNAKE_CASE_									=						self.tool(_A						,		'What did Hugging Face do in April 2021?')
      self.assertEqual(_A						,		'launched the BigScience Research Workshop')

  def 						lowerCAmelCase__     (					self):
      SCREAMING_SNAKE_CASE_									=						self.remote_tool(_A						,		'What did Hugging Face do in April 2021?')
      self.assertEqual(_A						,		'launched the BigScience Research Workshop')

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


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


