






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


UpperCAmelCase_ :						int      =      logging.get_logger(__name__)

UpperCAmelCase_ :						Any      =      {
    '''naver-clova-ix/donut-base''': '''https://huggingface.co/naver-clova-ix/donut-base/resolve/main/config.json''',
    # See all Donut models at https://huggingface.co/models?filter=donut-swin
}

class     _SCREAMING_SNAKE_CASE       (			_a      ):
	snake_case__							:     str     	=  """donut-swin"""

	snake_case__							:     str     	=  {
	    """num_attention_heads""": """num_heads""",
	    """num_hidden_layers""": """num_layers""",
	}





	def __init__(		self				:					List[Any] ,  __lowerCamelCase				:					Union[str, Any]=224 ,  __lowerCamelCase				:					Optional[int]=4 ,  __lowerCamelCase				:					str=3 ,  __lowerCamelCase				:					Dict=96 ,  __lowerCamelCase				:					Dict=[2, 2, 6, 2] ,  __lowerCamelCase				:					List[Any]=[3, 6, 12, 24] ,  __lowerCamelCase				:					int=7 ,  __lowerCamelCase				:					int=4.0 ,  __lowerCamelCase				:					Dict=True ,  __lowerCamelCase				:					Dict=0.0 ,  __lowerCamelCase				:					Any=0.0 ,  __lowerCamelCase				:					List[Any]=0.1 ,  __lowerCamelCase				:					Optional[Any]="gelu" ,  __lowerCamelCase				:					Union[str, Any]=False ,  __lowerCamelCase				:					Dict=0.02 ,  __lowerCamelCase				:					Dict=1E-5 ,  **__lowerCamelCase				:					Dict ,  ):
		super().__init__(**__lowerCamelCase	)

		UpperCamelCase     :Tuple          =	image_size
		UpperCamelCase     :Optional[Any]          =	patch_size
		UpperCamelCase     :Union[str, Any]          =	num_channels
		UpperCamelCase     :Tuple          =	embed_dim
		UpperCamelCase     :str          =	depths
		UpperCamelCase     :Any          =	len(__lowerCamelCase	)
		UpperCamelCase     :Optional[int]          =	num_heads
		UpperCamelCase     :Union[str, Any]          =	window_size
		UpperCamelCase     :Optional[Any]          =	mlp_ratio
		UpperCamelCase     :List[Any]          =	qkv_bias
		UpperCamelCase     :Any          =	hidden_dropout_prob
		UpperCamelCase     :Any          =	attention_probs_dropout_prob
		UpperCamelCase     :List[Any]          =	drop_path_rate
		UpperCamelCase     :int          =	hidden_act
		UpperCamelCase     :Union[str, Any]          =	use_absolute_embeddings
		UpperCamelCase     :int          =	layer_norm_eps
		UpperCamelCase     :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
		UpperCamelCase     :Any          =	int(embed_dim * 2 ** (len(__lowerCamelCase	) - 1)	)








# Copyright 2023 The HuggingFace Inc. team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from ..models.whisper import WhisperForConditionalGeneration, WhisperProcessor
from .base import PipelineTool

class     _SCREAMING_SNAKE_CASE       (			_a      ):
	snake_case__							:     Any     	=  """openai/whisper-base"""
	snake_case__							:     Optional[int]     	=  (
	    """This is a tool that transcribes an audio into text. It takes an input named `audio` and returns the """
	    """transcribed text."""
	)
	snake_case__							:     Any     	=  """transcriber"""
	snake_case__							:     Optional[int]     	=  WhisperProcessor
	snake_case__							:     str     	=  WhisperForConditionalGeneration

	snake_case__							:     Optional[Any]     	=  ["""audio"""]
	snake_case__							:     Any     	=  ["""text"""]





	def 						_A (		self				:					str ,  __lowerCamelCase				:					Dict	):
		return self.pre_processor(__lowerCamelCase ,  return_tensors="""pt"""	).input_features





	def 						_A (		self				:					Dict ,  __lowerCamelCase				:					List[Any]	):
		return self.model.generate(inputs=__lowerCamelCase	)





	def 						_A (		self				:					Any ,  __lowerCamelCase				:					Optional[Any]	):
		return self.pre_processor.batch_decode(__lowerCamelCase ,  skip_special_tokens=__lowerCamelCase	)[0]
