'''simple docstring'''




from ..utils import DummyObject, requires_backends




class    a__				(       metaclass=UpperCAmelCase__			):
     lowerCamelCase  :					List[Any]							=["flax"]






     def __init__(			self		:		Union[str, Any]  ,    *a		:		Optional[int]  ,    **a		:		Dict   ):





         """simple docstring"""



         requires_backends(self  ,    ['''flax''']   )






     @classmethod
     def        SCREAMING_SNAKE_CASE__       (			cls		:		int  ,    *a		:		Optional[Any]  ,    **a		:		str   ):





         """simple docstring"""



         requires_backends(cls  ,    ['''flax''']   )






     @classmethod
     def        SCREAMING_SNAKE_CASE__       (			cls		:		Optional[Any]  ,    *a		:		Optional[Any]  ,    **a		:		int   ):





         """simple docstring"""



         requires_backends(cls  ,    ['''flax''']   )




class    a__				(       metaclass=UpperCAmelCase__			):
     lowerCamelCase  :					Any							=["flax"]






     def __init__(			self		:		Dict  ,    *a		:		Dict  ,    **a		:		Union[str, Any]   ):





         """simple docstring"""



         requires_backends(self  ,    ['''flax''']   )






     @classmethod
     def        SCREAMING_SNAKE_CASE__       (			cls		:		int  ,    *a		:		str  ,    **a		:		List[str]   ):





         """simple docstring"""



         requires_backends(cls  ,    ['''flax''']   )






     @classmethod
     def        SCREAMING_SNAKE_CASE__       (			cls		:		Any  ,    *a		:		Tuple  ,    **a		:		List[str]   ):





         """simple docstring"""



         requires_backends(cls  ,    ['''flax''']   )




class    a__				(       metaclass=UpperCAmelCase__			):
     lowerCamelCase  :					int							=["flax"]






     def __init__(			self		:		Optional[Any]  ,    *a		:		List[str]  ,    **a		:		int   ):





         """simple docstring"""



         requires_backends(self  ,    ['''flax''']   )






     @classmethod
     def        SCREAMING_SNAKE_CASE__       (			cls		:		int  ,    *a		:		List[str]  ,    **a		:		List[Any]   ):





         """simple docstring"""



         requires_backends(cls  ,    ['''flax''']   )






     @classmethod
     def        SCREAMING_SNAKE_CASE__       (			cls		:		Dict  ,    *a		:		List[str]  ,    **a		:		List[Any]   ):





         """simple docstring"""



         requires_backends(cls  ,    ['''flax''']   )




class    a__				(       metaclass=UpperCAmelCase__			):
     lowerCamelCase  :					Dict							=["flax"]






     def __init__(			self		:		Optional[int]  ,    *a		:		Union[str, Any]  ,    **a		:		str   ):





         """simple docstring"""



         requires_backends(self  ,    ['''flax''']   )






     @classmethod
     def        SCREAMING_SNAKE_CASE__       (			cls		:		List[Any]  ,    *a		:		Any  ,    **a		:		List[str]   ):





         """simple docstring"""



         requires_backends(cls  ,    ['''flax''']   )






     @classmethod
     def        SCREAMING_SNAKE_CASE__       (			cls		:		int  ,    *a		:		Optional[Any]  ,    **a		:		Any   ):





         """simple docstring"""



         requires_backends(cls  ,    ['''flax''']   )




class    a__				(       metaclass=UpperCAmelCase__			):
     lowerCamelCase  :					Optional[Any]							=["flax"]






     def __init__(			self		:		str  ,    *a		:		Optional[int]  ,    **a		:		Dict   ):





         """simple docstring"""



         requires_backends(self  ,    ['''flax''']   )






     @classmethod
     def        SCREAMING_SNAKE_CASE__       (			cls		:		int  ,    *a		:		Dict  ,    **a		:		List[str]   ):





         """simple docstring"""



         requires_backends(cls  ,    ['''flax''']   )






     @classmethod
     def        SCREAMING_SNAKE_CASE__       (			cls		:		Optional[int]  ,    *a		:		Any  ,    **a		:		List[str]   ):





         """simple docstring"""



         requires_backends(cls  ,    ['''flax''']   )




class    a__				(       metaclass=UpperCAmelCase__			):
     lowerCamelCase  :					Union[str, Any]							=["flax"]






     def __init__(			self		:		Optional[int]  ,    *a		:		str  ,    **a		:		int   ):





         """simple docstring"""



         requires_backends(self  ,    ['''flax''']   )






     @classmethod
     def        SCREAMING_SNAKE_CASE__       (			cls		:		int  ,    *a		:		int  ,    **a		:		str   ):





         """simple docstring"""



         requires_backends(cls  ,    ['''flax''']   )






     @classmethod
     def        SCREAMING_SNAKE_CASE__       (			cls		:		int  ,    *a		:		str  ,    **a		:		Optional[int]   ):





         """simple docstring"""



         requires_backends(cls  ,    ['''flax''']   )




class    a__				(       metaclass=UpperCAmelCase__			):
     lowerCamelCase  :					Tuple							=["flax"]






     def __init__(			self		:		Optional[int]  ,    *a		:		int  ,    **a		:		List[Any]   ):





         """simple docstring"""



         requires_backends(self  ,    ['''flax''']   )






     @classmethod
     def        SCREAMING_SNAKE_CASE__       (			cls		:		str  ,    *a		:		Optional[int]  ,    **a		:		Optional[int]   ):





         """simple docstring"""



         requires_backends(cls  ,    ['''flax''']   )






     @classmethod
     def        SCREAMING_SNAKE_CASE__       (			cls		:		Optional[int]  ,    *a		:		Optional[int]  ,    **a		:		str   ):





         """simple docstring"""



         requires_backends(cls  ,    ['''flax''']   )




class    a__				(       metaclass=UpperCAmelCase__			):
     lowerCamelCase  :					Optional[int]							=["flax"]






     def __init__(			self		:		Union[str, Any]  ,    *a		:		Union[str, Any]  ,    **a		:		Union[str, Any]   ):





         """simple docstring"""



         requires_backends(self  ,    ['''flax''']   )






     @classmethod
     def        SCREAMING_SNAKE_CASE__       (			cls		:		List[Any]  ,    *a		:		Optional[int]  ,    **a		:		Dict   ):





         """simple docstring"""



         requires_backends(cls  ,    ['''flax''']   )






     @classmethod
     def        SCREAMING_SNAKE_CASE__       (			cls		:		List[str]  ,    *a		:		List[Any]  ,    **a		:		List[str]   ):





         """simple docstring"""



         requires_backends(cls  ,    ['''flax''']   )




class    a__				(       metaclass=UpperCAmelCase__			):
     lowerCamelCase  :					List[str]							=["flax"]






     def __init__(			self		:		Tuple  ,    *a		:		Dict  ,    **a		:		int   ):





         """simple docstring"""



         requires_backends(self  ,    ['''flax''']   )






     @classmethod
     def        SCREAMING_SNAKE_CASE__       (			cls		:		List[str]  ,    *a		:		Optional[int]  ,    **a		:		Any   ):





         """simple docstring"""



         requires_backends(cls  ,    ['''flax''']   )






     @classmethod
     def        SCREAMING_SNAKE_CASE__       (			cls		:		List[Any]  ,    *a		:		Union[str, Any]  ,    **a		:		Optional[int]   ):





         """simple docstring"""



         requires_backends(cls  ,    ['''flax''']   )




class    a__				(       metaclass=UpperCAmelCase__			):
     lowerCamelCase  :					str							=["flax"]






     def __init__(			self		:		int  ,    *a		:		Any  ,    **a		:		Optional[int]   ):





         """simple docstring"""



         requires_backends(self  ,    ['''flax''']   )






     @classmethod
     def        SCREAMING_SNAKE_CASE__       (			cls		:		Optional[int]  ,    *a		:		List[Any]  ,    **a		:		Union[str, Any]   ):





         """simple docstring"""



         requires_backends(cls  ,    ['''flax''']   )






     @classmethod
     def        SCREAMING_SNAKE_CASE__       (			cls		:		Optional[Any]  ,    *a		:		str  ,    **a		:		Optional[int]   ):





         """simple docstring"""



         requires_backends(cls  ,    ['''flax''']   )




class    a__				(       metaclass=UpperCAmelCase__			):
     lowerCamelCase  :					List[str]							=["flax"]






     def __init__(			self		:		Tuple  ,    *a		:		str  ,    **a		:		Any   ):





         """simple docstring"""



         requires_backends(self  ,    ['''flax''']   )






     @classmethod
     def        SCREAMING_SNAKE_CASE__       (			cls		:		int  ,    *a		:		Optional[Any]  ,    **a		:		int   ):





         """simple docstring"""



         requires_backends(cls  ,    ['''flax''']   )






     @classmethod
     def        SCREAMING_SNAKE_CASE__       (			cls		:		str  ,    *a		:		Tuple  ,    **a		:		Tuple   ):





         """simple docstring"""



         requires_backends(cls  ,    ['''flax''']   )




class    a__				(       metaclass=UpperCAmelCase__			):
     lowerCamelCase  :					Any							=["flax"]






     def __init__(			self		:		str  ,    *a		:		Union[str, Any]  ,    **a		:		str   ):





         """simple docstring"""



         requires_backends(self  ,    ['''flax''']   )






     @classmethod
     def        SCREAMING_SNAKE_CASE__       (			cls		:		List[str]  ,    *a		:		Optional[int]  ,    **a		:		Optional[int]   ):





         """simple docstring"""



         requires_backends(cls  ,    ['''flax''']   )






     @classmethod
     def        SCREAMING_SNAKE_CASE__       (			cls		:		List[str]  ,    *a		:		Optional[int]  ,    **a		:		int   ):





         """simple docstring"""



         requires_backends(cls  ,    ['''flax''']   )




class    a__				(       metaclass=UpperCAmelCase__			):
     lowerCamelCase  :					Any							=["flax"]






     def __init__(			self		:		Union[str, Any]  ,    *a		:		Any  ,    **a		:		Optional[int]   ):





         """simple docstring"""



         requires_backends(self  ,    ['''flax''']   )






     @classmethod
     def        SCREAMING_SNAKE_CASE__       (			cls		:		Union[str, Any]  ,    *a		:		Dict  ,    **a		:		Union[str, Any]   ):





         """simple docstring"""



         requires_backends(cls  ,    ['''flax''']   )






     @classmethod
     def        SCREAMING_SNAKE_CASE__       (			cls		:		Dict  ,    *a		:		str  ,    **a		:		Tuple   ):





         """simple docstring"""



         requires_backends(cls  ,    ['''flax''']   )

'''simple docstring'''




import time
import unittest

from transformers import is_torch_available
from transformers.testing_utils import require_torch, torch_device

from ..test_modeling_common import ids_tensor


if is_torch_available():
  import torch

  from transformers.generation import (
      MaxLengthCriteria,
      MaxNewTokensCriteria,
      MaxTimeCriteria,
      StoppingCriteriaList,
      validate_stopping_criteria,
  )




@require_torch
class    a__				(       unittest.TestCase			):






     def        SCREAMING_SNAKE_CASE__       (			self		:		Optional[int]  ,    a		:		int   ):





         """simple docstring"""



         __lowerCamelCase          =  3
         __lowerCamelCase          =  2_50

         __lowerCamelCase          =  ids_tensor((batch_size, length)  ,    a   )
         __lowerCamelCase          =  torch.ones((batch_size, length)  ,    device=a  ,    dtype=torch.float   ) / length
         return input_ids, scores






     def        SCREAMING_SNAKE_CASE__       (			self		:		List[Any]   ):





         """simple docstring"""



         __lowerCamelCase     ,  __lowerCamelCase          =  self._get_tensors(5   )

         __lowerCamelCase          =  StoppingCriteriaList(
             [
                 MaxLengthCriteria(max_length=10   ),
                 MaxTimeCriteria(max_time=0.1   ),
             ]   )

         self.assertFalse(criteria(a  ,    a   )   )

         __lowerCamelCase     ,  __lowerCamelCase          =  self._get_tensors(9   )
         self.assertFalse(criteria(a  ,    a   )   )

         __lowerCamelCase     ,  __lowerCamelCase          =  self._get_tensors(10   )
         self.assertTrue(criteria(a  ,    a   )   )






     def        SCREAMING_SNAKE_CASE__       (			self		:		Union[str, Any]   ):





         """simple docstring"""



         __lowerCamelCase          =  MaxLengthCriteria(max_length=10   )

         __lowerCamelCase     ,  __lowerCamelCase          =  self._get_tensors(5   )
         self.assertFalse(criteria(a  ,    a   )   )

         __lowerCamelCase     ,  __lowerCamelCase          =  self._get_tensors(9   )
         self.assertFalse(criteria(a  ,    a   )   )

         __lowerCamelCase     ,  __lowerCamelCase          =  self._get_tensors(10   )
         self.assertTrue(criteria(a  ,    a   )   )






     def        SCREAMING_SNAKE_CASE__       (			self		:		List[Any]   ):





         """simple docstring"""



         __lowerCamelCase          =  MaxNewTokensCriteria(start_length=5  ,    max_new_tokens=5   )

         __lowerCamelCase     ,  __lowerCamelCase          =  self._get_tensors(5   )
         self.assertFalse(criteria(a  ,    a   )   )

         __lowerCamelCase     ,  __lowerCamelCase          =  self._get_tensors(9   )
         self.assertFalse(criteria(a  ,    a   )   )

         __lowerCamelCase     ,  __lowerCamelCase          =  self._get_tensors(10   )
         self.assertTrue(criteria(a  ,    a   )   )

         __lowerCamelCase          =  StoppingCriteriaList([criteria]   )
         self.assertEqual(criteria_list.max_length  ,    10   )






     def        SCREAMING_SNAKE_CASE__       (			self		:		int   ):





         """simple docstring"""



         __lowerCamelCase     ,  __lowerCamelCase          =  self._get_tensors(5   )

         __lowerCamelCase          =  MaxTimeCriteria(max_time=0.1   )
         self.assertFalse(criteria(a  ,    a   )   )

         __lowerCamelCase          =  MaxTimeCriteria(max_time=0.1  ,    initial_timestamp=time.time() - 0.2   )
         self.assertTrue(criteria(a  ,    a   )   )






     def        SCREAMING_SNAKE_CASE__       (			self		:		List[Any]   ):





         """simple docstring"""



         validate_stopping_criteria(StoppingCriteriaList([MaxLengthCriteria(10   )]   )  ,    10   )

         with self.assertWarns(a   ):
             validate_stopping_criteria(StoppingCriteriaList([MaxLengthCriteria(10   )]   )  ,    11   )

         __lowerCamelCase          =  validate_stopping_criteria(StoppingCriteriaList()  ,    11   )

         self.assertEqual(len(a   )  ,    1   )
