
'''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 							snake_case				(		UpperCAmelCase						)->      Tuple:







      """simple docstring"""
      __A													=      tmp_path / 'file.jsonl'
      __A													=      textwrap.dedent(
          '\\n        {"col_1": -1}\n        {"col_1": 1, "col_2": 2}\n        {"col_1": 10, "col_2": 20}\n        '						)
      with open(UpperCAmelCase   ,	'w'						) as f:
            f.write(UpperCAmelCase						)
      return str(UpperCAmelCase						)





@pytest.fixture
def 							snake_case				(		UpperCAmelCase						)->      Any:







      """simple docstring"""
      __A													=      tmp_path / 'file_utf16_encoded.jsonl'
      __A													=      textwrap.dedent(
          '\\n        {"col_1": -1}\n        {"col_1": 1, "col_2": 2}\n        {"col_1": 10, "col_2": 20}\n        '						)
      with open(UpperCAmelCase   ,	'w'   ,	encoding='utf-16'						) as f:
            f.write(UpperCAmelCase						)
      return str(UpperCAmelCase						)





@pytest.fixture
def 							snake_case				(		UpperCAmelCase						)->      Optional[int]:







      """simple docstring"""
      __A													=      tmp_path / 'file_with_list_of_dicts.json'
      __A													=      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(UpperCAmelCase   ,	'w'						) as f:
            f.write(UpperCAmelCase						)
      return str(UpperCAmelCase						)





@pytest.fixture
def 							snake_case				(		UpperCAmelCase						)->      Optional[Any]:







      """simple docstring"""
      __A													=      tmp_path / 'file_with_list_of_dicts_field.json'
      __A													=      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(UpperCAmelCase   ,	'w'						) as f:
            f.write(UpperCAmelCase						)
      return str(UpperCAmelCase						)





@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 							snake_case				(		UpperCAmelCase   ,	UpperCAmelCase   ,	UpperCAmelCase						)->      List[str]:







      """simple docstring"""
      __A													=      Json(**UpperCAmelCase						)
      __A													=      json._generate_tables([[request.getfixturevalue(UpperCAmelCase						)]]						)
      __A													=      pa.concat_tables([table for _, table in generator]						)
      assert pa_table.to_pydict() == {"col_1": [-1, 1, 1_0], "col_2": [None, 2, 2_0]}





@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 							snake_case				(		UpperCAmelCase   ,	UpperCAmelCase   ,	UpperCAmelCase						)->      Dict:







      """simple docstring"""
      __A													=      Json(**UpperCAmelCase						)
      __A													=      json._generate_tables([[request.getfixturevalue(UpperCAmelCase						)]]						)
      __A													=      pa.concat_tables([table for _, table in generator]						)
      assert pa_table.to_pydict() == {"col_1": [-1, 1, 1_0], "col_2": [None, 2, 2_0], "missing_col": [None, None, None]}







'''simple docstring'''




from dataclasses import dataclass
from typing import List, Optional, Union

import numpy as np
import PIL
from PIL import Image

from ...utils import BaseOutput, is_torch_available, is_transformers_available


@dataclass
# Copied from diffusers.pipelines.stable_diffusion.__init__.StableDiffusionPipelineOutput with Stable->Alt
class    UpperCAmelCase__	(							_snake_case      ):






   """simple docstring"""
   A				:							Union[List[PIL.Image.Image], np.ndarray]
   A				:							Optional[List[bool]]


if is_transformers_available() and is_torch_available():
 from .modeling_roberta_series import RobertaSeriesModelWithTransformation
 from .pipeline_alt_diffusion import AltDiffusionPipeline
 from .pipeline_alt_diffusion_imgaimg import AltDiffusionImgaImgPipeline




