


"""simple docstring"""





import doctest
import logging
import os
import unittest
from pathlib import Path
from typing import List, Union

import transformers
from transformers.testing_utils import require_tf, require_torch, slow


snake_case__		:     Tuple    				=				logging.getLogger()



@unittest.skip('''Temporarily disable the doc tests.'''			)
@require_torch
@require_tf
@slow
class 		snake_case_(       unittest.TestCase			):






     def      lowerCamelCase__     (	self  :					Dict					,				UpperCamelCase_  :					Path					,				UpperCamelCase_  :					Union[str, None] = None					,				UpperCamelCase_  :					Union[List[str], None] = None					,				UpperCamelCase_  :					Union[str, List[str], None] = None					,				UpperCamelCase_  :					bool = True					,				):
           lowerCAmelCase					:	str       =   [file for file in os.listdir(UpperCamelCase_				) if os.path.isfile(os.path.join(UpperCamelCase_					,				UpperCamelCase_				)				)]

           if identifier is not None:
                 lowerCAmelCase					:	str       =   [file for file in files if identifier in file]

           if n_identifier is not None:
                 if isinstance(UpperCamelCase_					,				UpperCamelCase_				):
                       for n_ in n_identifier:
                             lowerCAmelCase					:	str       =   [file for file in files if n_ not in file]
                 else:
                       lowerCAmelCase					:	List[str]       =   [file for file in files if n_identifier not in file]

           lowerCAmelCase					:	Optional[Any]       =   ignore_files or []
           ignore_files.append('''__init__.py'''				)
           lowerCAmelCase					:	List[str]       =   [file for file in files if file not in ignore_files]

           for file in files:
                 # Open all files
                 print('''Testing'''					,				UpperCamelCase_				)

                 if only_modules:
                       lowerCAmelCase					:	List[Any]       =   file.split('''.'''				)[0]
                       try:
                             lowerCAmelCase					:	Optional[int]       =   getattr(UpperCamelCase_					,				UpperCamelCase_				)
                             lowerCAmelCase					:	str       =   doctest.DocTestSuite(UpperCamelCase_				)
                             lowerCAmelCase					:	List[str]       =   unittest.TextTestRunner().run(UpperCamelCase_				)
                             self.assertIs(len(result.failures				)					,				0				)
                       except AttributeError:
                             logger.info(F'''{module_identifier} is not a module.'''				)
                 else:
                       lowerCAmelCase					:	Tuple       =   doctest.testfile(str('''..''' / directory / file				)					,				optionflags=doctest.ELLIPSIS				)
                       self.assertIs(result.failed					,				0				)






     def      lowerCamelCase__     (	self  :					Optional[int]				):
           lowerCAmelCase					:	Any       =   Path('''src/transformers'''				)
           lowerCAmelCase					:	Dict       =   '''modeling'''
           lowerCAmelCase					:	Optional[int]       =   [
               '''modeling_ctrl.py''',
               '''modeling_tf_ctrl.py''',
           ]
           self.analyze_directory(UpperCamelCase_					,				identifier=UpperCamelCase_					,				ignore_files=UpperCamelCase_				)






     def      lowerCamelCase__     (	self  :					List[Any]				):
           lowerCAmelCase					:	Any       =   Path('''src/transformers'''				)
           lowerCAmelCase					:	str       =   '''tokenization'''
           self.analyze_directory(UpperCamelCase_					,				identifier=UpperCamelCase_				)






     def      lowerCamelCase__     (	self  :					Union[str, Any]				):
           lowerCAmelCase					:	Union[str, Any]       =   Path('''src/transformers'''				)
           lowerCAmelCase					:	Optional[int]       =   '''configuration'''
           self.analyze_directory(UpperCamelCase_					,				identifier=UpperCamelCase_				)






     def      lowerCamelCase__     (	self  :					Optional[int]				):
           lowerCAmelCase					:	Any       =   Path('''src/transformers'''				)
           lowerCAmelCase					:	List[Any]       =   ['''configuration''', '''modeling''', '''tokenization''']
           self.analyze_directory(UpperCamelCase_					,				n_identifier=UpperCamelCase_				)






     def      lowerCamelCase__     (	self  :					Dict				):
           lowerCAmelCase					:	Any       =   Path('''docs/source'''				)
           lowerCAmelCase					:	int       =   ['''favicon.ico''']
           self.analyze_directory(UpperCamelCase_					,				ignore_files=UpperCamelCase_					,				only_modules=UpperCamelCase_				)






"""simple docstring"""





from torch import nn



class 		snake_case_(       nn.Module			):






     def __init__(	self  :					int					,				UpperCamelCase_  :					int					,				UpperCamelCase_  :					int				):
           super().__init__()
           lowerCAmelCase					:	str       =   class_size
           lowerCAmelCase					:	Dict       =   embed_size
           # self.mlp1 = nn.Linear(embed_size, embed_size)
           # self.mlp2 = (nn.Linear(embed_size, class_size))
           lowerCAmelCase					:	Any       =   nn.Linear(UpperCamelCase_					,				UpperCamelCase_				)






     def      lowerCamelCase__     (	self  :					List[Any]					,				UpperCamelCase_  :					Tuple				):
           # hidden_state = nn.functional.relu(self.mlp1(hidden_state))
           # hidden_state = self.mlp2(hidden_state)
           lowerCAmelCase					:	int       =   self.mlp(UpperCamelCase_				)
           return logits


