



"""simple docstring"""






import argparse
import json
import os
import sys
import tempfile
import unittest
from argparse import Namespace
from dataclasses import dataclass, field
from enum import Enum
from pathlib import Path
from typing import List, Literal, Optional

import yaml

from transformers import HfArgumentParser, TrainingArguments
from transformers.hf_argparser import make_choice_type_function, string_to_bool


# Since Python 3.10, we can use the builtin `|` operator for Union types
# See PEP 604: https://peps.python.org/pep-0604
_lowercase			:			Any										=						sys.version_info >= (3, 1_0)






def 					snake_case__       (		__lowerCamelCase    :   Dict=None							,		__lowerCamelCase    :   Tuple=None     ):
			"""simple docstring"""
			return field(default_factory=lambda: default							,		metadata=__lowerCamelCase     )

@dataclass
class 	__SCREAMING_SNAKE_CASE     :


					'''simple docstring'''





					_a             =							42
					_a             =							42
					_a             =							42
					_a             =							42





@dataclass
class 	__SCREAMING_SNAKE_CASE     :


					'''simple docstring'''





					_a             =							4_2
					_a             =							field(default='toto'		,       metadata={'help': 'help message'}       )





@dataclass
class 	__SCREAMING_SNAKE_CASE     :


					'''simple docstring'''





					_a             =							False
					_a             =							True
					_a             =							None





class 	__SCREAMING_SNAKE_CASE     (				lowerCAmelCase_       ):


					'''simple docstring'''





					_a             =							'titi'
					_a             =							'toto'





class 	__SCREAMING_SNAKE_CASE     (				lowerCAmelCase_       ):


					'''simple docstring'''





					_a             =							'titi'
					_a             =							'toto'
					_a             =							4_2





@dataclass
class 	__SCREAMING_SNAKE_CASE     :


					'''simple docstring'''





					_a             =							"toto"



					def 		snake_case	(	self							:  Any					)-> Dict:
								lowerCamelCase__		:		Dict		     =BasicEnum(self.foo					)





@dataclass
class 	__SCREAMING_SNAKE_CASE     :


					'''simple docstring'''





					_a             =							"toto"



					def 		snake_case	(	self							:  Dict					)-> List[str]:
								lowerCamelCase__		:		Union[str, Any]		     =MixedTypeEnum(self.foo					)





@dataclass
class 	__SCREAMING_SNAKE_CASE     :


					'''simple docstring'''





					_a             =							None
					_a             =							field(default=lowerCAmelCase_		,       metadata={'help': 'help message'}       )
					_a             =							None
					_a             =							list_field(default=[]       )
					_a             =							list_field(default=[]       )





@dataclass
class 	__SCREAMING_SNAKE_CASE     :


					'''simple docstring'''





					_a             =							list_field(default=[]       )
					_a             =							list_field(default=[1, 2, 3]       )
					_a             =							list_field(default=['Hallo', 'Bonjour', 'Hello']       )
					_a             =							list_field(default=[0.1, 0.2, 0.3]       )





@dataclass
class 	__SCREAMING_SNAKE_CASE     :


					'''simple docstring'''





					_a             =							field()
					_a             =							field()
					_a             =							field()



					def 		snake_case	(	self							:  Any					)-> Optional[Any]:
								lowerCamelCase__		:		List[Any]		     =BasicEnum(self.required_enum					)





@dataclass
class 	__SCREAMING_SNAKE_CASE     :


					'''simple docstring'''





					_a             =							42
					_a             =							field()
					_a             =							None
					_a             =							field(default='toto'		,       metadata={'help': 'help message'}       )
					_a             =							list_field(default=['Hallo', 'Bonjour', 'Hello']       )


if is_python_no_less_than_3_10:

		@dataclass
		class 	__SCREAMING_SNAKE_CASE     :


							'''simple docstring'''





							_a             =							False
							_a             =							True
							_a             =							None





		@dataclass
		class 	__SCREAMING_SNAKE_CASE     :


							'''simple docstring'''





							_a             =							None
							_a             =							field(default=lowerCAmelCase_		,       metadata={'help': 'help message'}       )
							_a             =							None
							_a             =							list_field(default=[]       )
							_a             =							list_field(default=[]       )

class 	__SCREAMING_SNAKE_CASE     (				unittest.TestCase       ):


					'''simple docstring'''





					def 		snake_case	(	self							:  List[str],  lowerCamelCase							:  argparse.ArgumentParser,  lowerCamelCase							:  argparse.ArgumentParser					)-> List[str]:
								self.assertEqual(len(a._actions					),  len(b._actions					)					)
								for x, y in zip(a._actions,  b._actions					):
											lowerCamelCase__		:		int		     ={k: v for k, v in vars(lowerCamelCase					).items() if k != '''container'''}
											lowerCamelCase__		:		List[Any]		     ={k: v for k, v in vars(lowerCamelCase					).items() if k != '''container'''}

											# Choices with mixed type have custom function as "type"
											# So we need to compare results directly for equality
											if xx.get('''choices''',  lowerCamelCase					) and yy.get('''choices''',  lowerCamelCase					):
														for expected_choice in yy["choices"] + xx["choices"]:
																	self.assertEqual(xx['''type'''](lowerCamelCase					),  yy['''type'''](lowerCamelCase					)					)
														del xx["type"], yy["type"]

											self.assertEqual(lowerCamelCase,  lowerCamelCase					)



					def 		snake_case	(	self							:  Optional[int]					)-> Optional[Any]:
								lowerCamelCase__		:		List[str]		     =HfArgumentParser(lowerCamelCase					)

								lowerCamelCase__		:		Union[str, Any]		     =argparse.ArgumentParser()
								expected.add_argument('''--foo''',  type=lowerCamelCase,  required=lowerCamelCase					)
								expected.add_argument('''--bar''',  type=lowerCamelCase,  required=lowerCamelCase					)
								expected.add_argument('''--baz''',  type=lowerCamelCase,  required=lowerCamelCase					)
								expected.add_argument('''--flag''',  type=lowerCamelCase,  default=lowerCamelCase,  const=lowerCamelCase,  nargs='''?'''					)
								self.argparsersEqual(lowerCamelCase,  lowerCamelCase					)

								lowerCamelCase__		:		Optional[int]		     =['''--foo''', '''1''', '''--baz''', '''quux''', '''--bar''', '''0.5''']
								((lowerCamelCase__)     ,       )		:		Optional[Any]		     =parser.parse_args_into_dataclasses(lowerCamelCase,  look_for_args_file=lowerCamelCase					)
								self.assertFalse(example.flag					)



					def 		snake_case	(	self							:  int					)-> Tuple:
								lowerCamelCase__		:		Tuple		     =HfArgumentParser(lowerCamelCase					)

								lowerCamelCase__		:		str		     =argparse.ArgumentParser()
								expected.add_argument('''--foo''',  default=42,  type=lowerCamelCase					)
								expected.add_argument('''--baz''',  default='''toto''',  type=lowerCamelCase,  help='''help message'''					)
								self.argparsersEqual(lowerCamelCase,  lowerCamelCase					)



					def 		snake_case	(	self							:  Optional[Any]					)-> int:
								lowerCamelCase__		:		Optional[Any]		     =argparse.ArgumentParser()
								expected.add_argument('''--foo''',  type=lowerCamelCase,  default=lowerCamelCase,  const=lowerCamelCase,  nargs='''?'''					)
								expected.add_argument('''--baz''',  type=lowerCamelCase,  default=lowerCamelCase,  const=lowerCamelCase,  nargs='''?'''					)
								# A boolean no_* argument always has to come after its "default: True" regular counter-part
								# and its default must be set to False
								expected.add_argument('''--no_baz''',  action='''store_false''',  default=lowerCamelCase,  dest='''baz'''					)
								expected.add_argument('''--opt''',  type=lowerCamelCase,  default=lowerCamelCase					)

								lowerCamelCase__		:		int		     =[WithDefaultBoolExample]
								if is_python_no_less_than_3_10:
											dataclass_types.append(lowerCamelCase					)

								for dataclass_type in dataclass_types:
											lowerCamelCase__		:		Any		     =HfArgumentParser(lowerCamelCase					)
											self.argparsersEqual(lowerCamelCase,  lowerCamelCase					)

											lowerCamelCase__		:		List[Any]		     =parser.parse_args([]					)
											self.assertEqual(lowerCamelCase,  Namespace(foo=lowerCamelCase,  baz=lowerCamelCase,  opt=lowerCamelCase					)					)

											lowerCamelCase__		:		Optional[Any]		     =parser.parse_args(['''--foo''', '''--no_baz''']					)
											self.assertEqual(lowerCamelCase,  Namespace(foo=lowerCamelCase,  baz=lowerCamelCase,  opt=lowerCamelCase					)					)

											lowerCamelCase__		:		Dict		     =parser.parse_args(['''--foo''', '''--baz''']					)
											self.assertEqual(lowerCamelCase,  Namespace(foo=lowerCamelCase,  baz=lowerCamelCase,  opt=lowerCamelCase					)					)

											lowerCamelCase__		:		Tuple		     =parser.parse_args(['''--foo''', '''True''', '''--baz''', '''True''', '''--opt''', '''True''']					)
											self.assertEqual(lowerCamelCase,  Namespace(foo=lowerCamelCase,  baz=lowerCamelCase,  opt=lowerCamelCase					)					)

											lowerCamelCase__		:		Optional[Any]		     =parser.parse_args(['''--foo''', '''False''', '''--baz''', '''False''', '''--opt''', '''False''']					)
											self.assertEqual(lowerCamelCase,  Namespace(foo=lowerCamelCase,  baz=lowerCamelCase,  opt=lowerCamelCase					)					)



					def 		snake_case	(	self							:  List[str]					)-> Any:
								lowerCamelCase__		:		Optional[int]		     =HfArgumentParser(lowerCamelCase					)

								lowerCamelCase__		:		Optional[Any]		     =argparse.ArgumentParser()
								expected.add_argument(
								    '''--foo''',  default='''toto''',  choices=['''titi''', '''toto''', 42],  type=make_choice_type_function(['''titi''', '''toto''', 42]					),  )
								self.argparsersEqual(lowerCamelCase,  lowerCamelCase					)

								lowerCamelCase__		:		Optional[int]		     =parser.parse_args([]					)
								self.assertEqual(args.foo,  '''toto'''					)
								lowerCamelCase__		:		str		     =parser.parse_args_into_dataclasses([]					)[0]
								self.assertEqual(enum_ex.foo,  MixedTypeEnum.toto					)

								lowerCamelCase__		:		List[str]		     =parser.parse_args(['''--foo''', '''titi''']					)
								self.assertEqual(args.foo,  '''titi'''					)
								lowerCamelCase__		:		Optional[Any]		     =parser.parse_args_into_dataclasses(['''--foo''', '''titi''']					)[0]
								self.assertEqual(enum_ex.foo,  MixedTypeEnum.titi					)

								lowerCamelCase__		:		Any		     =parser.parse_args(['''--foo''', '''42''']					)
								self.assertEqual(args.foo,  42					)
								lowerCamelCase__		:		str		     =parser.parse_args_into_dataclasses(['''--foo''', '''42''']					)[0]
								self.assertEqual(enum_ex.foo,  MixedTypeEnum.fourtytwo					)



					def 		snake_case	(	self							:  Dict					)-> str:

								@dataclass
								class 	__SCREAMING_SNAKE_CASE     :


													'''simple docstring'''





													_a             =							"toto"





								lowerCamelCase__		:		List[str]		     =HfArgumentParser(lowerCamelCase					)

								lowerCamelCase__		:		int		     =argparse.ArgumentParser()
								expected.add_argument(
								    '''--foo''',  default='''toto''',  choices=('''titi''', '''toto''', 42),  type=make_choice_type_function(['''titi''', '''toto''', 42]					),  )
								self.argparsersEqual(lowerCamelCase,  lowerCamelCase					)

								lowerCamelCase__		:		str		     =parser.parse_args([]					)
								self.assertEqual(args.foo,  '''toto'''					)

								lowerCamelCase__		:		Any		     =parser.parse_args(['''--foo''', '''titi''']					)
								self.assertEqual(args.foo,  '''titi'''					)

								lowerCamelCase__		:		Dict		     =parser.parse_args(['''--foo''', '''42''']					)
								self.assertEqual(args.foo,  42					)



					def 		snake_case	(	self							:  Tuple					)-> str:
								lowerCamelCase__		:		Optional[int]		     =HfArgumentParser(lowerCamelCase					)

								lowerCamelCase__		:		List[Any]		     =argparse.ArgumentParser()
								expected.add_argument('''--foo_int''',  nargs='''+''',  default=[],  type=lowerCamelCase					)
								expected.add_argument('''--bar_int''',  nargs='''+''',  default=[1, 2, 3],  type=lowerCamelCase					)
								expected.add_argument('''--foo_str''',  nargs='''+''',  default=['''Hallo''', '''Bonjour''', '''Hello'''],  type=lowerCamelCase					)
								expected.add_argument('''--foo_float''',  nargs='''+''',  default=[0.1, 0.2, 0.3],  type=lowerCamelCase					)

								self.argparsersEqual(lowerCamelCase,  lowerCamelCase					)

								lowerCamelCase__		:		int		     =parser.parse_args([]					)
								self.assertEqual(
								    lowerCamelCase,  Namespace(foo_int=[],  bar_int=[1, 2, 3],  foo_str=['''Hallo''', '''Bonjour''', '''Hello'''],  foo_float=[0.1, 0.2, 0.3]					),  )

								lowerCamelCase__		:		Optional[int]		     =parser.parse_args('''--foo_int 1 --bar_int 2 3 --foo_str a b c --foo_float 0.1 0.7'''.split()					)
								self.assertEqual(lowerCamelCase,  Namespace(foo_int=[1],  bar_int=[2, 3],  foo_str=['''a''', '''b''', '''c'''],  foo_float=[0.1, 0.7]					)					)



					def 		snake_case	(	self							:  Tuple					)-> List[Any]:
								lowerCamelCase__		:		int		     =argparse.ArgumentParser()
								expected.add_argument('''--foo''',  default=lowerCamelCase,  type=lowerCamelCase					)
								expected.add_argument('''--bar''',  default=lowerCamelCase,  type=lowerCamelCase,  help='''help message'''					)
								expected.add_argument('''--baz''',  default=lowerCamelCase,  type=lowerCamelCase					)
								expected.add_argument('''--ces''',  nargs='''+''',  default=[],  type=lowerCamelCase					)
								expected.add_argument('''--des''',  nargs='''+''',  default=[],  type=lowerCamelCase					)

								lowerCamelCase__		:		Optional[Any]		     =[OptionalExample]
								if is_python_no_less_than_3_10:
											dataclass_types.append(lowerCamelCase					)

								for dataclass_type in dataclass_types:
											lowerCamelCase__		:		Optional[Any]		     =HfArgumentParser(lowerCamelCase					)

											self.argparsersEqual(lowerCamelCase,  lowerCamelCase					)

											lowerCamelCase__		:		List[str]		     =parser.parse_args([]					)
											self.assertEqual(lowerCamelCase,  Namespace(foo=lowerCamelCase,  bar=lowerCamelCase,  baz=lowerCamelCase,  ces=[],  des=[]					)					)

											lowerCamelCase__		:		Dict		     =parser.parse_args('''--foo 12 --bar 3.14 --baz 42 --ces a b c --des 1 2 3'''.split()					)
											self.assertEqual(lowerCamelCase,  Namespace(foo=12,  bar=3.14,  baz='''42''',  ces=['''a''', '''b''', '''c'''],  des=[1, 2, 3]					)					)



					def 		snake_case	(	self							:  List[str]					)-> Optional[Any]:
								lowerCamelCase__		:		Dict		     =HfArgumentParser(lowerCamelCase					)

								lowerCamelCase__		:		Optional[Any]		     =argparse.ArgumentParser()
								expected.add_argument('''--required_list''',  nargs='''+''',  type=lowerCamelCase,  required=lowerCamelCase					)
								expected.add_argument('''--required_str''',  type=lowerCamelCase,  required=lowerCamelCase					)
								expected.add_argument(
								    '''--required_enum''',  type=make_choice_type_function(['''titi''', '''toto''']					),  choices=['''titi''', '''toto'''],  required=lowerCamelCase,  )
								self.argparsersEqual(lowerCamelCase,  lowerCamelCase					)



					def 		snake_case	(	self							:  Any					)-> Tuple:
								lowerCamelCase__		:		int		     =HfArgumentParser(lowerCamelCase					)

								lowerCamelCase__		:		Tuple		     =argparse.ArgumentParser()
								expected.add_argument('''--foo''',  type=lowerCamelCase,  required=lowerCamelCase					)
								expected.add_argument(
								    '''--required_enum''',  type=make_choice_type_function(['''titi''', '''toto''']					),  choices=['''titi''', '''toto'''],  required=lowerCamelCase,  )
								expected.add_argument('''--opt''',  type=lowerCamelCase,  default=lowerCamelCase					)
								expected.add_argument('''--baz''',  default='''toto''',  type=lowerCamelCase,  help='''help message'''					)
								expected.add_argument('''--foo_str''',  nargs='''+''',  default=['''Hallo''', '''Bonjour''', '''Hello'''],  type=lowerCamelCase					)
								self.argparsersEqual(lowerCamelCase,  lowerCamelCase					)



					def 		snake_case	(	self							:  str					)-> str:
								lowerCamelCase__		:		Optional[Any]		     =HfArgumentParser(lowerCamelCase					)

								lowerCamelCase__		:		List[str]		     ={
								    '''foo''': 12,
								    '''bar''': 3.14,
								    '''baz''': '''42''',
								    '''flag''': True,
								}

								lowerCamelCase__		:		List[Any]		     =parser.parse_dict(lowerCamelCase					)[0]
								lowerCamelCase__		:		List[Any]		     =BasicExample(**lowerCamelCase					)
								self.assertEqual(lowerCamelCase,  lowerCamelCase					)



					def 		snake_case	(	self							:  Optional[int]					)-> List[str]:
								lowerCamelCase__		:		List[Any]		     =HfArgumentParser(lowerCamelCase					)

								lowerCamelCase__		:		List[str]		     ={
								    '''foo''': 12,
								    '''bar''': 3.14,
								    '''baz''': '''42''',
								    '''flag''': True,
								    '''extra''': 42,
								}

								self.assertRaises(lowerCamelCase,  parser.parse_dict,  lowerCamelCase,  allow_extra_keys=lowerCamelCase					)



					def 		snake_case	(	self							:  Optional[Any]					)-> Optional[Any]:
								lowerCamelCase__		:		List[Any]		     =HfArgumentParser(lowerCamelCase					)

								lowerCamelCase__		:		Optional[int]		     ={
								    '''foo''': 12,
								    '''bar''': 3.14,
								    '''baz''': '''42''',
								    '''flag''': True,
								}
								with tempfile.TemporaryDirectory() as tmp_dir:
											lowerCamelCase__		:		str		     =os.path.join(lowerCamelCase,  '''temp_json'''					)
											os.mkdir(lowerCamelCase					)
											with open(temp_local_path + '''.json''',  '''w+'''					) as f:
														json.dump(lowerCamelCase,  lowerCamelCase					)
											lowerCamelCase__		:		Union[str, Any]		     =parser.parse_yaml_file(Path(temp_local_path + '''.json'''					)					)[0]

								lowerCamelCase__		:		Tuple		     =BasicExample(**lowerCamelCase					)
								self.assertEqual(lowerCamelCase,  lowerCamelCase					)



					def 		snake_case	(	self							:  Any					)-> Union[str, Any]:
								lowerCamelCase__		:		Optional[Any]		     =HfArgumentParser(lowerCamelCase					)

								lowerCamelCase__		:		Optional[int]		     ={
								    '''foo''': 12,
								    '''bar''': 3.14,
								    '''baz''': '''42''',
								    '''flag''': True,
								}
								with tempfile.TemporaryDirectory() as tmp_dir:
											lowerCamelCase__		:		List[str]		     =os.path.join(lowerCamelCase,  '''temp_yaml'''					)
											os.mkdir(lowerCamelCase					)
											with open(temp_local_path + '''.yaml''',  '''w+'''					) as f:
														yaml.dump(lowerCamelCase,  lowerCamelCase					)
											lowerCamelCase__		:		Dict		     =parser.parse_yaml_file(Path(temp_local_path + '''.yaml'''					)					)[0]
								lowerCamelCase__		:		Tuple		     =BasicExample(**lowerCamelCase					)
								self.assertEqual(lowerCamelCase,  lowerCamelCase					)




					def 		snake_case	(	self							:  str					)-> List[Any]:
								lowerCamelCase__		:		Any		     =HfArgumentParser(lowerCamelCase					)
								self.assertIsNotNone(lowerCamelCase					)









"""simple docstring"""






import gc
import unittest

from diffusers import FlaxControlNetModel, FlaxStableDiffusionControlNetPipeline
from diffusers.utils import is_flax_available, load_image, slow
from diffusers.utils.testing_utils import require_flax


if is_flax_available():
		import jax
		import jax.numpy as jnp
		from flax.jax_utils import replicate
		from flax.training.common_utils import shard

@slow
@require_flax
class 	__SCREAMING_SNAKE_CASE     (				unittest.TestCase       ):


					'''simple docstring'''





					def 		snake_case	(	self							:  Union[str, Any]					)-> Dict:
								# clean up the VRAM after each test
								super().tearDown()
								gc.collect()



					def 		snake_case	(	self							:  str					)-> Any:
								lowerCamelCase__     ,       lowerCamelCase__		:		Optional[Any]		     =FlaxControlNetModel.from_pretrained(
								    '''lllyasviel/sd-controlnet-canny''',  from_pt=lowerCamelCase,  dtype=jnp.bfloataa					)
								lowerCamelCase__     ,       lowerCamelCase__		:		Optional[int]		     =FlaxStableDiffusionControlNetPipeline.from_pretrained(
								    '''runwayml/stable-diffusion-v1-5''',  controlnet=lowerCamelCase,  from_pt=lowerCamelCase,  dtype=jnp.bfloataa					)
								lowerCamelCase__		:		Optional[int]		     =controlnet_params

								lowerCamelCase__		:		Dict		     ='''bird'''
								lowerCamelCase__		:		List[str]		     =jax.device_count()
								lowerCamelCase__		:		Optional[Any]		     =pipe.prepare_text_inputs([prompts] * num_samples					)

								lowerCamelCase__		:		Dict		     =load_image(
								    '''https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/sd_controlnet/bird_canny.png'''					)
								lowerCamelCase__		:		List[Any]		     =pipe.prepare_image_inputs([canny_image] * num_samples					)

								lowerCamelCase__		:		Optional[int]		     =jax.random.PRNGKey(0					)
								lowerCamelCase__		:		Dict		     =jax.random.split(lowerCamelCase,  jax.device_count()					)

								lowerCamelCase__		:		Tuple		     =replicate(lowerCamelCase					)
								lowerCamelCase__		:		Tuple		     =shard(lowerCamelCase					)
								lowerCamelCase__		:		Optional[int]		     =shard(lowerCamelCase					)

								lowerCamelCase__		:		Tuple		     =pipe(
								    prompt_ids=lowerCamelCase,  image=lowerCamelCase,  params=lowerCamelCase,  prng_seed=lowerCamelCase,  num_inference_steps=50,  jit=lowerCamelCase,  ).images
								assert images.shape == (jax.device_count(), 1, 768, 512, 3)

								lowerCamelCase__		:		Dict		     =images.reshape((images.shape[0] * images.shape[1],) + images.shape[-3:]					)
								lowerCamelCase__		:		Any		     =images[0, 253:256, 253:256, -1]

								lowerCamelCase__		:		Optional[Any]		     =jnp.asarray(jax.device_get(image_slice.flatten()					)					)
								lowerCamelCase__		:		Dict		     =jnp.array(
								    [0.167_969, 0.116_699, 0.081_543, 0.154_297, 0.132_812, 0.108_887, 0.169_922, 0.169_922, 0.205_078]					)
								print(F'''output_slice: {output_slice}'''					)
								assert jnp.abs(output_slice - expected_slice					).max() < 1E-2




					def 		snake_case	(	self							:  Optional[int]					)-> Optional[int]:
								lowerCamelCase__     ,       lowerCamelCase__		:		Dict		     =FlaxControlNetModel.from_pretrained(
								    '''lllyasviel/sd-controlnet-openpose''',  from_pt=lowerCamelCase,  dtype=jnp.bfloataa					)
								lowerCamelCase__     ,       lowerCamelCase__		:		List[Any]		     =FlaxStableDiffusionControlNetPipeline.from_pretrained(
								    '''runwayml/stable-diffusion-v1-5''',  controlnet=lowerCamelCase,  from_pt=lowerCamelCase,  dtype=jnp.bfloataa					)
								lowerCamelCase__		:		Optional[Any]		     =controlnet_params

								lowerCamelCase__		:		int		     ='''Chef in the kitchen'''
								lowerCamelCase__		:		Optional[Any]		     =jax.device_count()
								lowerCamelCase__		:		Any		     =pipe.prepare_text_inputs([prompts] * num_samples					)

								lowerCamelCase__		:		Any		     =load_image(
								    '''https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/sd_controlnet/pose.png'''					)
								lowerCamelCase__		:		List[Any]		     =pipe.prepare_image_inputs([pose_image] * num_samples					)

								lowerCamelCase__		:		Tuple		     =jax.random.PRNGKey(0					)
								lowerCamelCase__		:		Optional[Any]		     =jax.random.split(lowerCamelCase,  jax.device_count()					)

								lowerCamelCase__		:		int		     =replicate(lowerCamelCase					)
								lowerCamelCase__		:		List[Any]		     =shard(lowerCamelCase					)
								lowerCamelCase__		:		int		     =shard(lowerCamelCase					)

								lowerCamelCase__		:		Tuple		     =pipe(
								    prompt_ids=lowerCamelCase,  image=lowerCamelCase,  params=lowerCamelCase,  prng_seed=lowerCamelCase,  num_inference_steps=50,  jit=lowerCamelCase,  ).images
								assert images.shape == (jax.device_count(), 1, 768, 512, 3)

								lowerCamelCase__		:		Dict		     =images.reshape((images.shape[0] * images.shape[1],) + images.shape[-3:]					)
								lowerCamelCase__		:		List[str]		     =images[0, 253:256, 253:256, -1]

								lowerCamelCase__		:		int		     =jnp.asarray(jax.device_get(image_slice.flatten()					)					)
								lowerCamelCase__		:		Any		     =jnp.array(
								    [[0.271_484, 0.261_719, 0.275_391, 0.277_344, 0.279_297, 0.291_016, 0.294_922, 0.302_734, 0.302_734]]					)
								print(F'''output_slice: {output_slice}'''					)
								assert jnp.abs(output_slice - expected_slice					).max() < 1E-2




