





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        SCREAMING_SNAKE_CASE__					(		unittest.TestCase ):



 def __init__(				self,__lowerCamelCase					):
        A__		   =		parent




 def 							UpperCamelCase     (				self					):
        return {}


def       UpperCamelCase__(			)->Union[str, Any]:
       A__		   =		'''<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>'''

       A__		   =		'''
    <!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        SCREAMING_SNAKE_CASE__					(		UpperCamelCase__							,   unittest.TestCase ):
 __SCREAMING_SNAKE_CASE							=      MarkupLMFeatureExtractor if is_bsa_available() else None



 def 							UpperCamelCase     (				self					):
        A__		   =		MarkupLMFeatureExtractionTester(self					)



 @property
 def 							UpperCamelCase     (				self					):
        return self.feature_extract_tester.prepare_feat_extract_dict()




 def 							UpperCamelCase     (				self					):
        # Initialize feature_extractor
        A__		   =		self.feature_extraction_class()

        # Test not batched input
        A__		   =		get_html_strings()[0]
        A__		   =		feature_extractor(__lowerCamelCase					)

        # fmt: off
        A__		   =		[['''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''']]
        A__		   =		[['''/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
        A__		   =		get_html_strings()
        A__		   =		feature_extractor(__lowerCamelCase					)

        # fmt: off
        A__		   =		expected_nodes + [['''My First Heading''', '''My first paragraph.''']]
        A__		   =		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					)












import unittest
from dataclasses import dataclass

import pytest

from accelerate.commands.config.config_args import SageMakerConfig
from accelerate.utils import ComputeEnvironment
from accelerate.utils.launch import _convert_nargs_to_dict




@dataclass
class        SCREAMING_SNAKE_CASE__					(		UpperCamelCase__ ):
 __SCREAMING_SNAKE_CASE							=      ComputeEnvironment.AMAZON_SAGEMAKER
 __SCREAMING_SNAKE_CASE							=      True
 __SCREAMING_SNAKE_CASE							=      '''ml.p3.2xlarge'''
 __SCREAMING_SNAKE_CASE							=      '''accelerate_sagemaker_execution_role'''
 __SCREAMING_SNAKE_CASE							=      '''hf-sm'''
 __SCREAMING_SNAKE_CASE							=      '''us-east-1'''
 __SCREAMING_SNAKE_CASE							=      1
 __SCREAMING_SNAKE_CASE							=      '''accelerate-sagemaker-1'''
 __SCREAMING_SNAKE_CASE							=      '''1.6'''
 __SCREAMING_SNAKE_CASE							=      '''4.4'''
 __SCREAMING_SNAKE_CASE							=      '''train.py'''
 __SCREAMING_SNAKE_CASE							=      [
     '''--model_name_or_path''',
     '''bert''',
     '''--do_train''',
     '''False''',
     '''--epochs''',
     '''3''',
     '''--learning_rate''',
     '''5e-5''',
     '''--max_steps''',
     '''50.5''',
 ]
 __SCREAMING_SNAKE_CASE							=      [
     '''--model_name_or_path''',
     '''bert''',
     '''--do_train''',
     '''--do_test''',
     '''False''',
     '''--do_predict''',
     '''--epochs''',
     '''3''',
     '''--learning_rate''',
     '''5e-5''',
     '''--max_steps''',
     '''50.5''',
 ]




class        SCREAMING_SNAKE_CASE__					(		unittest.TestCase ):



 def 							UpperCamelCase     (				self					):
        # If no defaults are changed, `to_kwargs` returns an empty dict.
        A__		   =		_convert_nargs_to_dict(MockLaunchConfig.success_training_script_args					)
        assert isinstance(converted_args['''model_name_or_path'''],__lowerCamelCase					)
        assert isinstance(converted_args['''do_train'''],__lowerCamelCase					)
        assert isinstance(converted_args['''epochs'''],__lowerCamelCase					)
        assert isinstance(converted_args['''learning_rate'''],__lowerCamelCase					)
        assert isinstance(converted_args['''max_steps'''],__lowerCamelCase					)

        with pytest.raises(__lowerCamelCase					):
               _convert_nargs_to_dict(MockLaunchConfig.fail_training_script_args					)





