


"""simple docstring"""
import textwrap

import pyarrow as pa
import pytest

from datasets import Features, Value
from datasets.packaged_modules.json.json import Json






@pytest.fixture
def 						lowercase				(	_snake_case		: Tuple	)	->Dict:
	"""simple docstring"""





	__snake_case      :		List[str]         =							tmp_path / '''file.jsonl'''
	__snake_case      :		Optional[Any]         =							textwrap.dedent(
	    '''\
        {"col_1": -1}
        {"col_1": 1, "col_2": 2}
        {"col_1": 10, "col_2": 20}
        '''	)
	with open(_snake_case	,  '''w'''	) as f:
		f.write(_snake_case	)
	return str(_snake_case	)






@pytest.fixture
def 						lowercase				(	_snake_case		: Tuple	)	->Any:
	"""simple docstring"""





	__snake_case      :		List[str]         =							tmp_path / '''file_utf16_encoded.jsonl'''
	__snake_case      :		Dict         =							textwrap.dedent(
	    '''\
        {"col_1": -1}
        {"col_1": 1, "col_2": 2}
        {"col_1": 10, "col_2": 20}
        '''	)
	with open(_snake_case	,  '''w'''	,  encoding='''utf-16'''	) as f:
		f.write(_snake_case	)
	return str(_snake_case	)






@pytest.fixture
def 						lowercase				(	_snake_case		: Tuple	)	->Tuple:
	"""simple docstring"""





	__snake_case      :		Union[str, Any]         =							tmp_path / '''file_with_list_of_dicts.json'''
	__snake_case      :		int         =							textwrap.dedent(
	    '''\
        [
            {"col_1": -1},
            {"col_1": 1, "col_2": 2},
            {"col_1": 10, "col_2": 20}
        ]
        '''	)
	with open(_snake_case	,  '''w'''	) as f:
		f.write(_snake_case	)
	return str(_snake_case	)






@pytest.fixture
def 						lowercase				(	_snake_case		: str	)	->Any:
	"""simple docstring"""





	__snake_case      :		Optional[int]         =							tmp_path / '''file_with_list_of_dicts_field.json'''
	__snake_case      :		Optional[Any]         =							textwrap.dedent(
	    '''\
        {
            "field1": 1,
            "field2": "aabb",
            "field3": [
                {"col_1": -1},
                {"col_1": 1, "col_2": 2},
                {"col_1": 10, "col_2": 20}
            ]
        }
        '''	)
	with open(_snake_case	,  '''w'''	) as f:
		f.write(_snake_case	)
	return str(_snake_case	)






@pytest.mark.parametrize(
    '''file_fixture, config_kwargs'''	,  [
        ('''jsonl_file''', {}),
        ('''jsonl_file_utf16_encoded''', {'''encoding''': '''utf-16'''}),
        ('''json_file_with_list_of_dicts''', {}),
        ('''json_file_with_list_of_dicts_field''', {'''field''': '''field3'''}),
    ]	,  )
def 						lowercase				(	_snake_case		: List[Any]	,  _snake_case		: Tuple	,  _snake_case		: int	)	->int:
	"""simple docstring"""





	__snake_case      :		Any         =							Json(**_snake_case	)
	__snake_case      :		str         =							json._generate_tables([[request.getfixturevalue(_snake_case	)]]	)
	__snake_case      :		str         =							pa.concat_tables([table for _, table in generator]	)
	assert pa_table.to_pydict() == {"col_1": [-1, 1, 10], "col_2": [None, 2, 20]}






@pytest.mark.parametrize(
    '''file_fixture, config_kwargs'''	,  [
        (
            '''jsonl_file''',
            {'''features''': Features({'''col_1''': Value('''int64'''	), '''col_2''': Value('''int64'''	), '''missing_col''': Value('''string'''	)}	)},
        ),
        (
            '''json_file_with_list_of_dicts''',
            {'''features''': Features({'''col_1''': Value('''int64'''	), '''col_2''': Value('''int64'''	), '''missing_col''': Value('''string'''	)}	)},
        ),
        (
            '''json_file_with_list_of_dicts_field''',
            {
                '''field''': '''field3''',
                '''features''': Features(
                    {'''col_1''': Value('''int64'''	), '''col_2''': Value('''int64'''	), '''missing_col''': Value('''string'''	)}	),
            },
        ),
    ]	,  )
def 						lowercase				(	_snake_case		: List[Any]	,  _snake_case		: Tuple	,  _snake_case		: Optional[int]	)	->str:
	"""simple docstring"""





	__snake_case      :		Tuple         =							Json(**_snake_case	)
	__snake_case      :		Optional[Any]         =							json._generate_tables([[request.getfixturevalue(_snake_case	)]]	)
	__snake_case      :		Optional[Any]         =							pa.concat_tables([table for _, table in generator]	)
	assert pa_table.to_pydict() == {"col_1": [-1, 1, 10], "col_2": [None, 2, 20], "missing_col": [None, None, None]}






"""simple docstring"""




from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_tf_available,
    is_tokenizers_available,
    is_torch_available,
)


__lowerCamelCase									=	{
    "configuration_layoutlm": ["LAYOUTLM_PRETRAINED_CONFIG_ARCHIVE_MAP", "LayoutLMConfig", "LayoutLMOnnxConfig"],
    "tokenization_layoutlm": ["LayoutLMTokenizer"],
}

try:
				if not is_tokenizers_available():
								raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
				pass
else:
				__lowerCamelCase									=	["LayoutLMTokenizerFast"]

try:
				if not is_torch_available():
								raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
				pass
else:
				__lowerCamelCase									=	[
				    "LAYOUTLM_PRETRAINED_MODEL_ARCHIVE_LIST",
				    "LayoutLMForMaskedLM",
				    "LayoutLMForSequenceClassification",
				    "LayoutLMForTokenClassification",
				    "LayoutLMForQuestionAnswering",
				    "LayoutLMModel",
				    "LayoutLMPreTrainedModel",
				]

try:
				if not is_tf_available():
								raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
				pass
else:
				__lowerCamelCase									=	[
				    "TF_LAYOUTLM_PRETRAINED_MODEL_ARCHIVE_LIST",
				    "TFLayoutLMForMaskedLM",
				    "TFLayoutLMForSequenceClassification",
				    "TFLayoutLMForTokenClassification",
				    "TFLayoutLMForQuestionAnswering",
				    "TFLayoutLMMainLayer",
				    "TFLayoutLMModel",
				    "TFLayoutLMPreTrainedModel",
				]


if TYPE_CHECKING:
				from .configuration_layoutlm import LAYOUTLM_PRETRAINED_CONFIG_ARCHIVE_MAP, LayoutLMConfig, LayoutLMOnnxConfig
				from .tokenization_layoutlm import LayoutLMTokenizer

				try:
								if not is_tokenizers_available():
												raise OptionalDependencyNotAvailable()
				except OptionalDependencyNotAvailable:
								pass
				else:
								from .tokenization_layoutlm_fast import LayoutLMTokenizerFast

				try:
								if not is_torch_available():
												raise OptionalDependencyNotAvailable()
				except OptionalDependencyNotAvailable:
								pass
				else:
								from .modeling_layoutlm import (
								    LAYOUTLM_PRETRAINED_MODEL_ARCHIVE_LIST,
								    LayoutLMForMaskedLM,
								    LayoutLMForQuestionAnswering,
								    LayoutLMForSequenceClassification,
								    LayoutLMForTokenClassification,
								    LayoutLMModel,
								    LayoutLMPreTrainedModel,
								)
				try:
								if not is_tf_available():
												raise OptionalDependencyNotAvailable()
				except OptionalDependencyNotAvailable:
								pass
				else:
								from .modeling_tf_layoutlm import (
								    TF_LAYOUTLM_PRETRAINED_MODEL_ARCHIVE_LIST,
								    TFLayoutLMForMaskedLM,
								    TFLayoutLMForQuestionAnswering,
								    TFLayoutLMForSequenceClassification,
								    TFLayoutLMForTokenClassification,
								    TFLayoutLMMainLayer,
								    TFLayoutLMModel,
								    TFLayoutLMPreTrainedModel,
								)

else:
				import sys

				__lowerCamelCase									=	_LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)





