





'''simple docstring'''




from ...configuration_utils import PretrainedConfig
from ...utils import logging


__UpperCAmelCase            =       logging.get_logger(__name__)

__UpperCAmelCase            =       {
    """google/fnet-base""": """https://huggingface.co/google/fnet-base/resolve/main/config.json""",
    """google/fnet-large""": """https://huggingface.co/google/fnet-large/resolve/main/config.json"""
    # See all FNet models at https://huggingface.co/models?filter=fnet
}




class      UpperCamelCase__					(					lowercase_			):




					"""simple docstring"""
					SCREAMING_SNAKE_CASE__				=	'''fnet'''


					def __init__(						self				:			Any      ,						lowerCamelCase_				:			List[str]=3_20_00      ,						lowerCamelCase_				:			List[Any]=7_68      ,						lowerCamelCase_				:			Union[str, Any]=12      ,						lowerCamelCase_				:			Optional[Any]=30_72      ,						lowerCamelCase_				:			Optional[Any]="gelu_new"      ,						lowerCamelCase_				:			Any=0.1      ,						lowerCamelCase_				:			Union[str, Any]=5_12      ,						lowerCamelCase_				:			Optional[int]=4      ,						lowerCamelCase_				:			Optional[int]=0.02      ,						lowerCamelCase_				:			str=1e-12      ,						lowerCamelCase_				:			Any=False      ,						lowerCamelCase_				:			str=5_12      ,						lowerCamelCase_				:			str=3      ,						lowerCamelCase_				:			int=1      ,						lowerCamelCase_				:			Optional[Any]=2      ,						**lowerCamelCase_				:			Optional[int]      ,						):

							'''simple docstring'''



							super().__init__(pad_token_id=lowerCamelCase_      ,						bos_token_id=lowerCamelCase_      ,						eos_token_id=lowerCamelCase_      ,						**lowerCamelCase_						)

							SCREAMING_SNAKE_CASE :				Dict		=			vocab_size
							SCREAMING_SNAKE_CASE :				Dict		=			max_position_embeddings
							SCREAMING_SNAKE_CASE :				str		=			hidden_size
							SCREAMING_SNAKE_CASE :				Optional[Any]		=			num_hidden_layers
							SCREAMING_SNAKE_CASE :				Union[str, Any]		=			intermediate_size
							SCREAMING_SNAKE_CASE :				int		=			hidden_act
							SCREAMING_SNAKE_CASE :				Dict		=			hidden_dropout_prob
							SCREAMING_SNAKE_CASE :				Tuple		=			initializer_range
							SCREAMING_SNAKE_CASE :				List[Any]		=			type_vocab_size
							SCREAMING_SNAKE_CASE :				Any		=			layer_norm_eps
							SCREAMING_SNAKE_CASE :				int		=			use_tpu_fourier_optimizations
							SCREAMING_SNAKE_CASE :				List[Any]		=			tpu_short_seq_length










'''simple docstring'''




import unittest

from transformers.testing_utils import require_bsa
from transformers.utils import is_bsa_available

from ...test_feature_extraction_common import FeatureExtractionSavingTestMixin


if is_bsa_available():
							from transformers import MarkupLMFeatureExtractor




class      UpperCamelCase__					(					unittest.TestCase			):




					"""simple docstring"""


					def __init__(						self				:			str      ,						lowerCamelCase_				:			str						):

							'''simple docstring'''



							SCREAMING_SNAKE_CASE :				List[str]		=			parent



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

							'''simple docstring'''



							return {}







def 		__A		(  ):


		"""simple docstring"""



		SCREAMING_SNAKE_CASE :				Any		=			"""<HTML>

    <HEAD>
    <TITLE>sample document</TITLE>
    </HEAD>

    <BODY BGCOLOR=\"FFFFFF\">
    <HR>
    <a href=\"http://google.com\">Goog</a>
    <H1>This is one header</H1>
    <H2>This is a another Header</H2>
    <P>Travel from
        <P>
        <B>SFO to JFK</B>
        <BR>
        <B><I>on May 2, 2015 at 2:00 pm. For details go to confirm.com </I></B>
        <HR>
        <div style=\"color:#0000FF\">
            <h3>Traveler <b> name </b> is
            <p> John Doe </p>
        </div>"""

		SCREAMING_SNAKE_CASE :				int		=			"""
    <!DOCTYPE html>
    <html>
    <body>

    <h1>My First Heading</h1>
    <p>My first paragraph.</p>

    </body>
    </html>
    """

		return [html_string_a, html_string_a]




@require_bsa
class      UpperCamelCase__					(					lowercase_						,					unittest.TestCase			):




					"""simple docstring"""
					SCREAMING_SNAKE_CASE__				=	MarkupLMFeatureExtractor if is_bsa_available() else None


					def lowerCamelCase_			(						self				:			Optional[int]						):

							'''simple docstring'''



							SCREAMING_SNAKE_CASE :				int		=			MarkupLMFeatureExtractionTester(self						)


					@property
					def lowerCamelCase_			(						self				:			int						):

							'''simple docstring'''



							return self.feature_extract_tester.prepare_feat_extract_dict()



					def lowerCamelCase_			(						self				:			int						):

							'''simple docstring'''



							SCREAMING_SNAKE_CASE :				Union[str, Any]		=			self.feature_extraction_class()

							# Test not batched input
							SCREAMING_SNAKE_CASE :				Optional[int]		=			get_html_strings()[0]
							SCREAMING_SNAKE_CASE :				List[Any]		=			feature_extractor(lowerCamelCase_						)

							# fmt: off
							SCREAMING_SNAKE_CASE :				Optional[int]		=			[["""sample document""", """Goog""", """This is one header""", """This is a another Header""", """Travel from""", """SFO to JFK""", """on May 2, 2015 at 2:00 pm. For details go to confirm.com""", """Traveler""", """name""", """is""", """John Doe"""]]
							SCREAMING_SNAKE_CASE :				List[str]		=			[["""/html/head/title""", """/html/body/a""", """/html/body/h1""", """/html/body/h2""", """/html/body/p""", """/html/body/p/p/b[1]""", """/html/body/p/p/b[2]/i""", """/html/body/p/p/div/h3""", """/html/body/p/p/div/h3/b""", """/html/body/p/p/div/h3""", """/html/body/p/p/div/h3/p"""]]
							# fmt: on

							self.assertEqual(encoding.nodes      ,						lowerCamelCase_						)
							self.assertEqual(encoding.xpaths      ,						lowerCamelCase_						)

							# Test batched
							SCREAMING_SNAKE_CASE :				str		=			get_html_strings()
							SCREAMING_SNAKE_CASE :				str		=			feature_extractor(lowerCamelCase_						)

							# fmt: off
							SCREAMING_SNAKE_CASE :				int		=			expected_nodes + [["""My First Heading""", """My first paragraph."""]]
							SCREAMING_SNAKE_CASE :				List[Any]		=			expected_xpaths + [["""/html/body/h1""", """/html/body/p"""]]

							self.assertEqual(len(encoding.nodes						)      ,						2						)
							self.assertEqual(len(encoding.xpaths						)      ,						2						)

							self.assertEqual(encoding.nodes      ,						lowerCamelCase_						)
							self.assertEqual(encoding.xpaths      ,						lowerCamelCase_						)



