'''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        UpperCAmelCase__   (				_lowerCAmelCase    :			Union[str, Any])    ->		str:



						"""simple docstring"""

						snake_case :       Tuple				=    tmp_path / "file.jsonl"
						snake_case :       List[str]				=    textwrap.dedent(
						    "\\n        {\"col_1\": -1}\n        {\"col_1\": 1, \"col_2\": 2}\n        {\"col_1\": 10, \"col_2\": 20}\n        ")
						with open(_lowerCAmelCase,      "w") as f:
												f.write(_lowerCAmelCase)
						return str(_lowerCAmelCase)


@pytest.fixture
def        UpperCAmelCase__   (				_lowerCAmelCase    :			int)    ->		Tuple:



						"""simple docstring"""

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


@pytest.fixture
def        UpperCAmelCase__   (				_lowerCAmelCase    :			Optional[Any])    ->		int:



						"""simple docstring"""

						snake_case :       List[str]				=    tmp_path / "file_with_list_of_dicts.json"
						snake_case :       Dict				=    textwrap.dedent(
						    "\\n        [\n            {\"col_1\": -1},\n            {\"col_1\": 1, \"col_2\": 2},\n            {\"col_1\": 10, \"col_2\": 20}\n        ]\n        ")
						with open(_lowerCAmelCase,      "w") as f:
												f.write(_lowerCAmelCase)
						return str(_lowerCAmelCase)


@pytest.fixture
def        UpperCAmelCase__   (				_lowerCAmelCase    :			List[str])    ->		Optional[int]:



						"""simple docstring"""

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


@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        UpperCAmelCase__   (				_lowerCAmelCase    :			Any,      _lowerCAmelCase    :			Tuple,      _lowerCAmelCase    :			List[Any])    ->		Any:



						"""simple docstring"""

						snake_case :       Optional[Any]				=    Json(**_lowerCAmelCase)
						snake_case :       Any				=    json._generate_tables([[request.getfixturevalue(_lowerCAmelCase)]])
						snake_case :       int				=    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        UpperCAmelCase__   (				_lowerCAmelCase    :			Optional[Any],      _lowerCAmelCase    :			List[str],      _lowerCAmelCase    :			Any)    ->		Optional[Any]:



						"""simple docstring"""

						snake_case :       Any				=    Json(**_lowerCAmelCase)
						snake_case :       Optional[Any]				=    json._generate_tables([[request.getfixturevalue(_lowerCAmelCase)]])
						snake_case :       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'''

# Copyright 2023 The HuggingFace Team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from typing import TYPE_CHECKING

# rely on isort to merge the imports
from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_torch_available,
)


A_	   = {
    "configuration_convnextv2": [
        "CONVNEXTV2_PRETRAINED_CONFIG_ARCHIVE_MAP",
        "ConvNextV2Config",
    ]
}

try:
						if not is_torch_available():
												raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
						pass
else:
						A_	   = [
						    "CONVNEXTV2_PRETRAINED_MODEL_ARCHIVE_LIST",
						    "ConvNextV2ForImageClassification",
						    "ConvNextV2Model",
						    "ConvNextV2PreTrainedModel",
						    "ConvNextV2Backbone",
						]


if TYPE_CHECKING:
						from .configuration_convnextva import (
						    CONVNEXTV2_PRETRAINED_CONFIG_ARCHIVE_MAP,
						    ConvNextVaConfig,
						)

						try:
												if not is_torch_available():
																		raise OptionalDependencyNotAvailable()
						except OptionalDependencyNotAvailable:
												pass
						else:
												from .modeling_convnextva import (
												    CONVNEXTV2_PRETRAINED_MODEL_ARCHIVE_LIST,
												    ConvNextVaBackbone,
												    ConvNextVaForImageClassification,
												    ConvNextVaModel,
												    ConvNextVaPreTrainedModel,
												)

else:
						import sys

						A_	   = _LazyModule(__name__, globals()["__file__"], _import_structure)





