import time
import warnings
from abc import ABC
from copy import deepcopy
from typing import Optional

import torch

from ..utils import add_start_docstrings, logging


__a    :	Union[str, Any]         =    logging.get_logger(__name__)


__a    :	Union[str, Any]         =    r"""
    Args:
        input_ids (`torch.LongTensor` of shape `(batch_size, sequence_length)`):
            Indices of input sequence tokens in the vocabulary.

            Indices can be obtained using [`AutoTokenizer`]. See [`PreTrainedTokenizer.encode`] and
            [`PreTrainedTokenizer.__call__`] for details.

            [What are input IDs?](../glossary#input-ids)
        scores (`torch.FloatTensor` of shape `(batch_size, config.vocab_size)`):
            Prediction scores of a language modeling head. These can be scores for each vocabulary token before SoftMax
            or scores for each vocabulary token after SoftMax.
        kwargs (`Dict[str, Any]`, *optional*):
            Additional stopping criteria specific kwargs.

    Return:
        `bool`. `False` indicates we should continue, `True` indicates we should stop.

"""




class   _UpperCamelCase (		_UpperCAmelCase					):


			"""simple docstring"""






			@add_start_docstrings(lowerCAmelCase__		)
			def __call__(  self ,  lowerCAmelCase__ ,  lowerCAmelCase__ ,  **lowerCAmelCase__		)	->   bool:

							'''simple docstring'''


							raise NotImplementedError('''StoppingCriteria needs to be subclassed'''		)




class   _UpperCamelCase (		_UpperCAmelCase					):


			"""simple docstring"""






			def __init__(  self ,  lowerCAmelCase__ ,  lowerCAmelCase__ = None		)	->   str:

							'''simple docstring'''


							__lowercase					     =				max_length
							__lowercase					     =				max_position_embeddings





			@add_start_docstrings(lowerCAmelCase__		)
			def __call__(  self ,  lowerCAmelCase__ ,  lowerCAmelCase__ ,  **lowerCAmelCase__		)	->   bool:

							'''simple docstring'''


							__lowercase					     =				input_ids.shape[-1]
							__lowercase					     =				cur_len >= self.max_length
							if self.max_position_embeddings is not None and not is_done and cur_len >= self.max_position_embeddings:
											logger.warning_once(
											    '''This is a friendly reminder - the current text generation call will exceed the model\'s predefined '''
											    F"maximum length ({self.max_position_embeddings}). Depending on the model, you may observe "
											    '''exceptions, performance degradation, or nothing at all.'''		)
							return is_done




class   _UpperCamelCase (		_UpperCAmelCase					):


			"""simple docstring"""






			def __init__(  self ,  lowerCAmelCase__ ,  lowerCAmelCase__		)	->   Optional[int]:

							'''simple docstring'''


							warnings.warn(
							    '''The class `MaxNewTokensCriteria` is deprecated. '''
							    F"Please use `MaxLengthCriteria(max_length={start_length + max_new_tokens})` "
							    '''with `max_length = start_length + max_new_tokens` instead.''' ,  lowerCAmelCase__ ,  )
							__lowercase					     =				start_length
							__lowercase					     =				max_new_tokens
							__lowercase					     =				start_length + max_new_tokens





			@add_start_docstrings(lowerCAmelCase__		)
			def __call__(  self ,  lowerCAmelCase__ ,  lowerCAmelCase__ ,  **lowerCAmelCase__		)	->   bool:

							'''simple docstring'''


							return input_ids.shape[-1] >= self.max_length




class   _UpperCamelCase (		_UpperCAmelCase					):


			"""simple docstring"""






			def __init__(  self ,  lowerCAmelCase__ ,  lowerCAmelCase__ = None		)	->   Optional[Any]:

							'''simple docstring'''


							__lowercase					     =				max_time
							__lowercase					     =				time.time() if initial_timestamp is None else initial_timestamp





			@add_start_docstrings(lowerCAmelCase__		)
			def __call__(  self ,  lowerCAmelCase__ ,  lowerCAmelCase__ ,  **lowerCAmelCase__		)	->   bool:

							'''simple docstring'''


							return time.time() - self.initial_timestamp > self.max_time




class   _UpperCamelCase (		_UpperCAmelCase					):


			"""simple docstring"""






			@add_start_docstrings(lowerCAmelCase__		)
			def __call__(  self ,  lowerCAmelCase__ ,  lowerCAmelCase__ ,  **lowerCAmelCase__		)	->   bool:

							'''simple docstring'''


							return any(criteria(lowerCAmelCase__ ,  lowerCAmelCase__		) for criteria in self		)





			@property
			def 			_SCREAMING_SNAKE_CASE     (  self		)	->   Optional[int]:

							'''simple docstring'''


							for stopping_criterium in self:
											if isinstance(lowerCAmelCase__ ,  lowerCAmelCase__		):
															return stopping_criterium.max_length
											elif isinstance(lowerCAmelCase__ ,  lowerCAmelCase__		):
															return stopping_criterium.max_length
							return None





def 							UpperCAmelCase		(       lowercase				,     lowercase				):







				"""simple docstring"""



				__lowercase					     =				stopping_criteria.max_length
				__lowercase					     =				deepcopy(lowercase				)
				if stopping_max_length is not None and stopping_max_length != max_length:
								warnings.warn('''You set different `max_length` for stopping criteria and `max_length` parameter'''				,     lowercase				)
				elif stopping_max_length is None:
								new_stopping_criteria.append(MaxLengthCriteria(max_length=lowercase				)				)
				return new_stopping_criteria
from ...configuration_utils import PretrainedConfig
from ...utils import logging


__a    :	List[Any]         =    logging.get_logger(__name__)

__a    :	List[Any]         =    {
    """MIT/ast-finetuned-audioset-10-10-0.4593""": (
        """https://huggingface.co/MIT/ast-finetuned-audioset-10-10-0.4593/resolve/main/config.json"""
    ),
}




class   _UpperCamelCase (		_UpperCAmelCase					):


			"""simple docstring"""






			__a    :					Optional[Any]     					=		'''audio-spectrogram-transformer'''





			def __init__(  self ,  lowerCAmelCase__=7_68 ,  lowerCAmelCase__=12 ,  lowerCAmelCase__=12 ,  lowerCAmelCase__=30_72 ,  lowerCAmelCase__="gelu" ,  lowerCAmelCase__=0.0 ,  lowerCAmelCase__=0.0 ,  lowerCAmelCase__=0.02 ,  lowerCAmelCase__=1E-12 ,  lowerCAmelCase__=16 ,  lowerCAmelCase__=True ,  lowerCAmelCase__=10 ,  lowerCAmelCase__=10 ,  lowerCAmelCase__=10_24 ,  lowerCAmelCase__=1_28 ,  **lowerCAmelCase__ ,  )	->   Optional[Any]:

							'''simple docstring'''


							super().__init__(**lowerCAmelCase__		)

							__lowercase					     =				hidden_size
							__lowercase					     =				num_hidden_layers
							__lowercase					     =				num_attention_heads
							__lowercase					     =				intermediate_size
							__lowercase					     =				hidden_act
							__lowercase					     =				hidden_dropout_prob
							__lowercase					     =				attention_probs_dropout_prob
							__lowercase					     =				initializer_range
							__lowercase					     =				layer_norm_eps
							__lowercase					     =				patch_size
							__lowercase					     =				qkv_bias
							__lowercase					     =				frequency_stride
							__lowercase					     =				time_stride
							__lowercase					     =				max_length
							__lowercase					     =				num_mel_bins