





"""simple docstring"""





from typing import TYPE_CHECKING

from ..models.auto import AutoModelForVisionaSeq
from ..utils import requires_backends
from .base import PipelineTool


if TYPE_CHECKING:
    from PIL import Image





class      snake_case						(  _UpperCAmelCase  ):
      lowerCamelCase__         =					'Salesforce/blip-image-captioning-base'
      lowerCamelCase__         =					(
          'This is a tool that generates a description of an image. It takes an input named `image` which should be the '
          'image to caption, and returns a text that contains the description in English.'
      )
      lowerCamelCase__         =					'image_captioner'
      lowerCamelCase__         =					AutoModelForVisionaSeq

      lowerCamelCase__         =					['image']
      lowerCamelCase__         =					['text']

      def __init__(     self  :int		,				*_lowerCamelCase  :int		,				**_lowerCamelCase  :str		):
       requires_backends(self		,				['''vision''']		)
       super().__init__(*__UpperCamelCase		,				**__UpperCamelCase		)

      def 		SCREAMING_SNAKE_CASE_     (     self  :Tuple		,				_lowerCamelCase  :"Image"		):
       return self.pre_processor(images=__UpperCamelCase		,				return_tensors='''pt'''		)

      def 		SCREAMING_SNAKE_CASE_     (     self  :Optional[int]		,				_lowerCamelCase  :Dict		):
       return self.model.generate(**__UpperCamelCase		)



      def 		SCREAMING_SNAKE_CASE_     (     self  :List[Any]		,				_lowerCamelCase  :Optional[Any]		):
       return self.pre_processor.batch_decode(__UpperCamelCase		,				skip_special_tokens=__UpperCamelCase		)[0].strip()



"""simple docstring"""



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


a       :						Dict       		=		logging.get_logger(__name__)

# TODO: upload to AWS
a       :						Tuple       		=		{
    '''yjernite/retribert-base-uncased''': (
        '''https://huggingface.co/yjernite/retribert-base-uncased/resolve/main/config.json'''
    ),
}




class 		a_    (			_UpperCAmelCase						):
    a   :					int			     =					'retribert'







    def __init__(      self      :							Optional[Any]  ,       __UpperCamelCase      :							Optional[Any]=3_05_22  ,       __UpperCamelCase      :							int=7_68  ,       __UpperCamelCase      :							Any=8  ,       __UpperCamelCase      :							Dict=12  ,       __UpperCamelCase      :							List[Any]=30_72  ,       __UpperCamelCase      :							List[Any]="gelu"  ,       __UpperCamelCase      :							Optional[int]=0.1  ,       __UpperCamelCase      :							int=0.1  ,       __UpperCamelCase      :							Union[str, Any]=5_12  ,       __UpperCamelCase      :							Dict=2  ,       __UpperCamelCase      :							Tuple=0.0_2  ,       __UpperCamelCase      :							List[str]=1e-12  ,       __UpperCamelCase      :							int=True  ,       __UpperCamelCase      :							str=1_28  ,       __UpperCamelCase      :							Union[str, Any]=0  ,       **__UpperCamelCase      :							Any  ,       )		->List[Any]:






        '''simple docstring'''






        super().__init__(pad_token_id=__UpperCamelCase  ,       **__UpperCamelCase  )

        _UpperCAmelCase        = vocab_size
        _UpperCAmelCase        = hidden_size
        _UpperCAmelCase        = num_hidden_layers
        _UpperCAmelCase        = num_attention_heads
        _UpperCAmelCase        = hidden_act
        _UpperCAmelCase        = intermediate_size
        _UpperCAmelCase        = hidden_dropout_prob
        _UpperCAmelCase        = attention_probs_dropout_prob
        _UpperCAmelCase        = max_position_embeddings
        _UpperCAmelCase        = type_vocab_size
        _UpperCAmelCase        = initializer_range
        _UpperCAmelCase        = layer_norm_eps
        _UpperCAmelCase        = share_encoders
        _UpperCAmelCase        = projection_dim