



"""simple docstring"""
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      =				logging.get_logger(__name__)


__a      =				r"\n    Args:\n        input_ids (`torch.LongTensor` of shape `(batch_size, sequence_length)`):\n            Indices of input sequence tokens in the vocabulary.\n\n            Indices can be obtained using [`AutoTokenizer`]. See [`PreTrainedTokenizer.encode`] and\n            [`PreTrainedTokenizer.__call__`] for details.\n\n            [What are input IDs?](../glossary#input-ids)\n        scores (`torch.FloatTensor` of shape `(batch_size, config.vocab_size)`):\n            Prediction scores of a language modeling head. These can be scores for each vocabulary token before SoftMax\n            or scores for each vocabulary token after SoftMax.\n        kwargs (`Dict[str, Any]`, *optional*):\n            Additional stopping criteria specific kwargs.\n\n    Return:\n        `bool`. `False` indicates we should continue, `True` indicates we should stop.\n\n"
class 				lowerCamelCase  (			_lowerCAmelCase				):






					'''simple docstring'''





					@add_start_docstrings(snake_case						)
					def __call__(       self:							int						,     snake_case:							torch.LongTensor						,     snake_case:							torch.FloatTensor						,     **snake_case:							Optional[Any]						)   ->	bool:
											raise NotImplementedError("""StoppingCriteria needs to be subclassed"""						)

class 				lowerCamelCase  (			_lowerCAmelCase				):






					'''simple docstring'''





					def __init__(       self:							Any						,     snake_case:							int						,     snake_case:							Optional[int] = None						)   ->	List[str]:
											snake_case_ :Dict						=			max_length
											snake_case_ :Union[str, Any]						=			max_position_embeddings






					@add_start_docstrings(snake_case						)
					def __call__(       self:							Dict						,     snake_case:							torch.LongTensor						,     snake_case:							torch.FloatTensor						,     **snake_case:							str						)   ->	bool:
											snake_case_ :Dict						=			input_ids.shape[-1]
											snake_case_ :Union[str, Any]						=			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 				lowerCamelCase  (			_lowerCAmelCase				):






					'''simple docstring'''





					def __init__(       self:							Union[str, Any]						,     snake_case:							int						,     snake_case:							int						)   ->	Dict:
											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."""						,     snake_case						,     )
											snake_case_ :Union[str, Any]						=			start_length
											snake_case_ :int						=			max_new_tokens
											snake_case_ :int						=			start_length + max_new_tokens






					@add_start_docstrings(snake_case						)
					def __call__(       self:							Optional[int]						,     snake_case:							torch.LongTensor						,     snake_case:							torch.FloatTensor						,     **snake_case:							str						)   ->	bool:
											return input_ids.shape[-1] >= self.max_length

class 				lowerCamelCase  (			_lowerCAmelCase				):






					'''simple docstring'''





					def __init__(       self:							Optional[int]						,     snake_case:							float						,     snake_case:							Optional[float] = None						)   ->	Union[str, Any]:
											snake_case_ :Tuple						=			max_time
											snake_case_ :List[Any]						=			time.time() if initial_timestamp is None else initial_timestamp






					@add_start_docstrings(snake_case						)
					def __call__(       self:							Tuple						,     snake_case:							torch.LongTensor						,     snake_case:							torch.FloatTensor						,     **snake_case:							Union[str, Any]						)   ->	bool:
											return time.time() - self.initial_timestamp > self.max_time

class 				lowerCamelCase  (			_lowerCAmelCase				):






					'''simple docstring'''





					@add_start_docstrings(snake_case						)
					def __call__(       self:							str						,     snake_case:							torch.LongTensor						,     snake_case:							torch.FloatTensor						,     **snake_case:							int						)   ->	bool:
											return any(criteria(snake_case						,     snake_case						) for criteria in self						)






					@property
					def    lowerCAmelCase_				(       self:							Tuple						)   ->	Optional[int]:
											for stopping_criterium in self:
																	if isinstance(snake_case						,     snake_case						):
																							return stopping_criterium.max_length
																	elif isinstance(snake_case						,     snake_case						):
																							return stopping_criterium.max_length
											return None

def    A_  (			_lowercase,					_lowercase	):







						'''simple docstring'''


						snake_case_ :List[str]						=			stopping_criteria.max_length
						snake_case_ :List[str]						=			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





"""simple docstring"""
import re
def    A_  (			_lowercase	):







						'''simple docstring'''


						snake_case_ :Optional[int]						=			re.compile(
						    r"""^(?:0|94|\+94|0{2}94)""" r"""7(0|1|2|4|5|6|7|8)""" r"""(-| |)""" r"""\d{7}$"""	)

						return bool(re.search(_lowercase,					_lowercase	)	)


if __name__ == "__main__":
						__a      =				"0094702343221"

						print(is_sri_lankan_phone_number(phone))
