




from unittest import TestCase

from datasets import Sequence, Value
from datasets.arrow_dataset import Dataset







class __snake_case			(			a		):







   def lowerCamelCase						(      self		:						Tuple):

        """simple docstring"""


        return [
            {"col_1": 3, "col_2": "a"},
            {"col_1": 2, "col_2": "b"},
            {"col_1": 1, "col_2": "c"},
            {"col_1": 0, "col_2": "d"},
        ]







   def lowerCamelCase						(      self		:						Dict):

        """simple docstring"""


        UpperCAmelCase_          =							{'''col_1''': [3, 2, 1, 0], '''col_2''': ['''a''', '''b''', '''c''', '''d''']}
        return Dataset.from_dict(_snake_case)







   def lowerCamelCase						(      self		:						Tuple):

        """simple docstring"""


        UpperCAmelCase_          =							self._create_example_records()
        UpperCAmelCase_          =							Dataset.from_list(_snake_case)
        self.assertListEqual(dset.column_names					,						['''col_1''', '''col_2'''])
        for i, r in enumerate(_snake_case):
             self.assertDictEqual(_snake_case					,						example_records[i])







   def lowerCamelCase						(      self		:						str):

        """simple docstring"""


        UpperCAmelCase_          =							self._create_example_records()
        UpperCAmelCase_          =							Dataset.from_list(_snake_case)
        UpperCAmelCase_          =							Dataset.from_dict({k: [r[k] for r in example_records] for k in example_records[0]})
        self.assertEqual(dset.info					,						dset_from_dict.info)







   def lowerCamelCase						(      self		:						Optional[Any]):  # checks what happens with missing columns

        """simple docstring"""


        UpperCAmelCase_          =							[{'''col_1''': 1}, {'''col_2''': '''x'''}]
        UpperCAmelCase_          =							Dataset.from_list(_snake_case)
        self.assertDictEqual(dset[0]					,						{'''col_1''': 1})
        self.assertDictEqual(dset[1]					,						{'''col_1''': None})  # NB: first record is used for columns







   def lowerCamelCase						(      self		:						Any):  # checks if the type can be inferred from the second record

        """simple docstring"""


        UpperCAmelCase_          =							[{'''col_1''': []}, {'''col_1''': [1, 2]}]
        UpperCAmelCase_          =							Dataset.from_list(_snake_case)
        self.assertEqual(dset.info.features['''col_1''']					,						Sequence(Value('''int64''')))







   def lowerCamelCase						(      self		:						int):

        """simple docstring"""


        UpperCAmelCase_          =							Dataset.from_list([])
        self.assertEqual(len(_snake_case)					,						0)
        self.assertListEqual(dset.column_names					,						[])














'''simple docstring'''







import unittest

import numpy as np
import torch

from diffusers import VersatileDiffusionImageVariationPipeline
from diffusers.utils.testing_utils import load_image, require_torch_gpu, slow, torch_device


_A	:			Union[str, Any]         =False

class _lowercase	(				unittest.TestCase		):
							pass



@slow
@require_torch_gpu
class _lowercase	(				unittest.TestCase		):




							def 		lowerCamelCase_				(							self:				Optional[int]     ):
														lowerCamelCase__					:	Tuple         =       VersatileDiffusionImageVariationPipeline.from_pretrained("""shi-labs/versatile-diffusion"""     )
														pipe.to(UpperCamelCase__     )
														pipe.set_progress_bar_config(disable=UpperCamelCase__     )

														lowerCamelCase__					:	Optional[int]         =       load_image(
														    """https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/versatile_diffusion/benz.jpg"""     )
														lowerCamelCase__					:	List[Any]         =       torch.manual_seed(0     )
														lowerCamelCase__					:	List[Any]         =       pipe(
														    image=UpperCamelCase__			,							generator=UpperCamelCase__			,							guidance_scale=7.5			,							num_inference_steps=50			,							output_type="""numpy"""			,							).images

														lowerCamelCase__					:	List[str]         =       image[0, 253:256, 253:256, -1]

														assert image.shape == (1, 512, 512, 3)
														lowerCamelCase__					:	Tuple         =       np.array([0.0_441, 0.0_469, 0.0_507, 0.0_575, 0.0_632, 0.0_650, 0.0_865, 0.0_909, 0.0_945]     )

														assert np.abs(image_slice.flatten() - expected_slice     ).max() < 1e-2

