

import copy
from collections import OrderedDict
from typing import Mapping

from packaging import version

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


a_    :						int    		=      logging.get_logger(__name__)

a_    :						List[Any]    		=      {
    "microsoft/conditional-detr-resnet-50": (
        "https://huggingface.co/microsoft/conditional-detr-resnet-50/resolve/main/config.json"
    ),
}




class      UpperCamelCase (     SCREAMING_SNAKE_CASE   ):
    __UpperCamelCase         ="conditional_detr"
    __UpperCamelCase         =["past_key_values"]
    __UpperCamelCase         ={
        "hidden_size": "d_model",
        "num_attention_heads": "encoder_attention_heads",
    }

    def __init__(			self :      int							,    snake_case__ :      Optional[Any]=True							,    snake_case__ :      Optional[int]=None							,    snake_case__ :      Any=3							,    snake_case__ :      Any=3_0_0							,    snake_case__ :      Union[str, Any]=6							,    snake_case__ :      int=2_0_4_8							,    snake_case__ :      Tuple=8							,    snake_case__ :      List[Any]=6							,    snake_case__ :      Union[str, Any]=2_0_4_8							,    snake_case__ :      str=8							,    snake_case__ :      List[Any]=0.0							,    snake_case__ :      Union[str, Any]=0.0							,    snake_case__ :      int=True							,    snake_case__ :      Tuple="relu"							,    snake_case__ :      List[str]=2_5_6							,    snake_case__ :      Optional[int]=0.1							,    snake_case__ :      Tuple=0.0							,    snake_case__ :      Any=0.0							,    snake_case__ :      Any=0.02							,    snake_case__ :      List[str]=1.0							,    snake_case__ :      int=False							,    snake_case__ :      str="sine"							,    snake_case__ :      Dict="resnet50"							,    snake_case__ :      Tuple=True							,    snake_case__ :      List[Any]=False							,    snake_case__ :      Union[str, Any]=2							,    snake_case__ :      Union[str, Any]=5							,    snake_case__ :      Optional[Any]=2							,    snake_case__ :      Dict=1							,    snake_case__ :      str=1							,    snake_case__ :      str=2							,    snake_case__ :      Any=5							,    snake_case__ :      Optional[int]=2							,    snake_case__ :      List[Any]=0.25							,    **snake_case__ :      List[str]							,    ):

     """simple docstring"""






     if backbone_config is not None and use_timm_backbone:
      raise ValueError('You can\'t specify both `backbone_config` and `use_timm_backbone`.'    )

     if not use_timm_backbone:
      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=['stage4']    )
      elif isinstance(snake_case__							,    snake_case__    ):
       SCREAMING_SNAKE_CASE								=			backbone_config.get('model_type'    )
       SCREAMING_SNAKE_CASE								=			CONFIG_MAPPING[backbone_model_type]
       SCREAMING_SNAKE_CASE								=			config_class.from_dict(snake_case__    )

     SCREAMING_SNAKE_CASE								=			use_timm_backbone
     SCREAMING_SNAKE_CASE								=			backbone_config
     SCREAMING_SNAKE_CASE								=			num_channels
     SCREAMING_SNAKE_CASE								=			num_queries
     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								=			decoder_layerdrop
     SCREAMING_SNAKE_CASE								=			encoder_layers
     SCREAMING_SNAKE_CASE								=			auxiliary_loss
     SCREAMING_SNAKE_CASE								=			position_embedding_type
     SCREAMING_SNAKE_CASE								=			backbone
     SCREAMING_SNAKE_CASE								=			use_pretrained_backbone
     SCREAMING_SNAKE_CASE								=			dilation
     # 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								=			cls_loss_coefficient
     SCREAMING_SNAKE_CASE								=			bbox_loss_coefficient
     SCREAMING_SNAKE_CASE								=			giou_loss_coefficient
     SCREAMING_SNAKE_CASE								=			focal_alpha
     super().__init__(is_encoder_decoder=snake_case__							,    **snake_case__    )

    @property
    def UpperCamelCase			(			self :      Tuple    ):

     """simple docstring"""






     return self.encoder_attention_heads

    @property
    def UpperCamelCase			(			self :      Tuple    ):

     """simple docstring"""






     return self.d_model




    def UpperCamelCase			(			self :      List[Any]    ):

     """simple docstring"""






     SCREAMING_SNAKE_CASE								=			copy.deepcopy(self.__dict__    )
     if self.backbone_config is not None:
      SCREAMING_SNAKE_CASE								=			self.backbone_config.to_dict()
     SCREAMING_SNAKE_CASE								=			self.__class__.model_type
     return output




class      UpperCamelCase (     SCREAMING_SNAKE_CASE   ):
    __UpperCamelCase         =version.parse("1.11"   )

    @property
    def UpperCamelCase			(			self :      Optional[Any]    ):

     """simple docstring"""






     return OrderedDict(
         [
             ('pixel_values', {0: 'batch', 1: 'num_channels', 2: 'height', 3: 'width'}),
             ('pixel_mask', {0: 'batch'}),
         ]    )

    @property
    def UpperCamelCase			(			self :      Dict    ):

     """simple docstring"""






     return 1E-5




    @property
    def UpperCamelCase			(			self :      Any    ):

     """simple docstring"""






     return 1_2




# 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      UpperCamelCase (     SCREAMING_SNAKE_CASE   ):
    __UpperCamelCase         ="openai/whisper-base"
    __UpperCamelCase         =(
        "This is a tool that transcribes an audio into text. It takes an input named `audio` and returns the "
        "transcribed text."
    )
    __UpperCamelCase         ="transcriber"
    __UpperCamelCase         =WhisperProcessor
    __UpperCamelCase         =WhisperForConditionalGeneration

    __UpperCamelCase         =["audio"]
    __UpperCamelCase         =["text"]

    def UpperCamelCase			(			self :      Dict							,    snake_case__ :      Tuple    ):

     """simple docstring"""






     return self.pre_processor(snake_case__							,    return_tensors='pt'    ).input_features

    def UpperCamelCase			(			self :      Optional[int]							,    snake_case__ :      Tuple    ):

     """simple docstring"""






     return self.model.generate(inputs=snake_case__    )




    def UpperCamelCase			(			self :      str							,    snake_case__ :      Union[str, Any]    ):

     """simple docstring"""






     return self.pre_processor.batch_decode(snake_case__							,    skip_special_tokens=snake_case__    )[0]

