"""simple docstring"""




import os
import unittest

from transformers import FunnelTokenizer, FunnelTokenizerFast
from transformers.models.funnel.tokenization_funnel import VOCAB_FILES_NAMES
from transformers.testing_utils import require_tokenizers

from ...test_tokenization_common import TokenizerTesterMixin
@require_tokenizers
class     UpperCamelCase__(			__A		,						unittest.TestCase ):
						lowerCAmelCase__  :						Optional[Any]													=		FunnelTokenizer
						lowerCAmelCase__  :						Tuple													=		FunnelTokenizerFast
						lowerCAmelCase__  :						Optional[Any]													=		True
						lowerCAmelCase__  :						Dict													=		True





						def 				snake_case__	(       self     )					->				int:
													super().setUp()

													A__	     =							[
													    '<unk>',
													    '<cls>',
													    '<sep>',
													    'want',
													    '##want',
													    '##ed',
													    'wa',
													    'un',
													    'runn',
													    '##ing',
													    ',',
													    'low',
													    'lowest',
													]
													A__	     =							os.path.join(self.tmpdirname		,VOCAB_FILES_NAMES['vocab_file']     )
													with open(self.vocab_file		,'w'		,encoding='utf-8'     ) as vocab_writer:
																				vocab_writer.write(''.join([x + '\n' for x in vocab_tokens]     )     )





						def 				snake_case__	(       self		,**__UpperCAmelCase     )					->				List[str]:
													return FunnelTokenizer.from_pretrained(self.tmpdirname		,**__UpperCAmelCase     )





						def 				snake_case__	(       self		,**__UpperCAmelCase     )					->				Union[str, Any]:
													return FunnelTokenizerFast.from_pretrained(self.tmpdirname		,**__UpperCAmelCase     )





						def 				snake_case__	(       self		,__UpperCAmelCase     )					->				Union[str, Any]:
													A__	     =							'UNwant\u00E9d,running'
													A__	     =							'unwanted, running'
													return input_text, output_text





						def 				snake_case__	(       self     )					->				Union[str, Any]:
													A__	     =							self.tokenizer_class(self.vocab_file     )

													A__	     =							tokenizer.tokenize('UNwant\u00E9d,running'     )
													self.assertListEqual(__UpperCAmelCase		,['un', '##want', '##ed', ',', 'runn', '##ing']     )
													self.assertListEqual(tokenizer.convert_tokens_to_ids(__UpperCAmelCase     )		,[7, 4, 5, 10, 8, 9]     )





						def 				snake_case__	(       self     )					->				Dict:
													A__	     =							self.get_tokenizers(do_lower_case=__UpperCAmelCase     )
													for tokenizer in tokenizers:
																				A__	     =							tokenizer('UNwant\u00E9d,running'     )
																				A__	     =							len(inputs['input_ids']     ) - 1
																				self.assertListEqual(inputs['token_type_ids']		,[2] + [0] * sentence_len     )

																				A__	     =							tokenizer('UNwant\u00E9d,running'		,'UNwant\u00E9d,running'     )
																				self.assertListEqual(inputs['token_type_ids']		,[2] + [0] * sentence_len + [1] * sentence_len     )






"""simple docstring"""




import unittest

import torch
from torch import nn

from diffusers.models.activations import get_activation
class     UpperCamelCase__(			unittest.TestCase ):





						def 				snake_case__	(       self     )					->				str:
													A__	     =							get_activation('swish'     )

													self.assertIsInstance(__UpperCAmelCase		,nn.SiLU     )

													self.assertEqual(act(torch.tensor(-1_00		,dtype=torch.floataa     )     ).item()		,0     )
													self.assertNotEqual(act(torch.tensor(-1		,dtype=torch.floataa     )     ).item()		,0     )
													self.assertEqual(act(torch.tensor(0		,dtype=torch.floataa     )     ).item()		,0     )
													self.assertEqual(act(torch.tensor(20		,dtype=torch.floataa     )     ).item()		,20     )





						def 				snake_case__	(       self     )					->				Optional[Any]:
													A__	     =							get_activation('silu'     )

													self.assertIsInstance(__UpperCAmelCase		,nn.SiLU     )

													self.assertEqual(act(torch.tensor(-1_00		,dtype=torch.floataa     )     ).item()		,0     )
													self.assertNotEqual(act(torch.tensor(-1		,dtype=torch.floataa     )     ).item()		,0     )
													self.assertEqual(act(torch.tensor(0		,dtype=torch.floataa     )     ).item()		,0     )
													self.assertEqual(act(torch.tensor(20		,dtype=torch.floataa     )     ).item()		,20     )





						def 				snake_case__	(       self     )					->				List[str]:
													A__	     =							get_activation('mish'     )

													self.assertIsInstance(__UpperCAmelCase		,nn.Mish     )

													self.assertEqual(act(torch.tensor(-2_00		,dtype=torch.floataa     )     ).item()		,0     )
													self.assertNotEqual(act(torch.tensor(-1		,dtype=torch.floataa     )     ).item()		,0     )
													self.assertEqual(act(torch.tensor(0		,dtype=torch.floataa     )     ).item()		,0     )
													self.assertEqual(act(torch.tensor(20		,dtype=torch.floataa     )     ).item()		,20     )





						def 				snake_case__	(       self     )					->				List[str]:
													A__	     =							get_activation('gelu'     )

													self.assertIsInstance(__UpperCAmelCase		,nn.GELU     )

													self.assertEqual(act(torch.tensor(-1_00		,dtype=torch.floataa     )     ).item()		,0     )
													self.assertNotEqual(act(torch.tensor(-1		,dtype=torch.floataa     )     ).item()		,0     )
													self.assertEqual(act(torch.tensor(0		,dtype=torch.floataa     )     ).item()		,0     )
													self.assertEqual(act(torch.tensor(20		,dtype=torch.floataa     )     ).item()		,20     )





