



"""simple docstring"""





__lowerCAmelCase       :					Union[str, Any]      					=					[
    [0, 16, 13, 0, 0, 0],
    [0, 0, 10, 12, 0, 0],
    [0, 4, 0, 0, 14, 0],
    [0, 0, 9, 0, 0, 20],
    [0, 0, 0, 7, 0, 4],
    [0, 0, 0, 0, 0, 0],
]
def 	__lowerCAmelCase						(		__UpperCamelCase      :			Dict					, __UpperCamelCase      :			Optional[int]					, __UpperCamelCase      :			Any					, __UpperCamelCase      :			Any    ):


						'''simple docstring'''






						snake_case_   : Optional[Any]						=			[False] * len(__UpperCamelCase    )
						snake_case_   : str						=			[s]
						snake_case_   : Tuple						=			True

						while queue:
												snake_case_   : Dict						=			queue.pop(0    )
												for ind in range(len(graph[u]    )    ):
																		if visited[ind] is False and graph[u][ind] > 0:
																								queue.append(__UpperCamelCase    )
																								snake_case_   : Dict						=			True
																								snake_case_   : Tuple						=			u

						return visited[t]
def 	__lowerCAmelCase						(		__UpperCamelCase      :			Union[str, Any]					, __UpperCamelCase      :			Optional[int]					, __UpperCamelCase      :			Dict    ):


						'''simple docstring'''






						snake_case_   : Union[str, Any]						=			[-1] * (len(__UpperCamelCase    ))
						snake_case_   : Any						=			0
						snake_case_   : Optional[Any]						=			[]
						snake_case_   : List[str]						=			[i[:] for i in graph]  # Record original cut, copy.
						while bfs(__UpperCamelCase					, __UpperCamelCase					, __UpperCamelCase					, __UpperCamelCase    ):
												snake_case_   : Dict						=			float("""Inf"""    )
												snake_case_   : List[Any]						=			sink

												while s != source:
																		# Find the minimum value in select path
																		snake_case_   : Optional[int]						=			min(__UpperCamelCase					, graph[parent[s]][s]    )
																		snake_case_   : Dict						=			parent[s]

												max_flow += path_flow
												snake_case_   : Tuple						=			sink

												while v != source:
																		snake_case_   : int						=			parent[v]
																		graph[u][v] -= path_flow
																		graph[v][u] += path_flow
																		snake_case_   : Optional[int]						=			parent[v]

						for i in range(len(__UpperCamelCase    )    ):
												for j in range(len(graph[0]    )    ):
																		if graph[i][j] == 0 and temp[i][j] > 0:
																								res.append((i, j)    )

						return res


if __name__ == "__main__":
			print(mincut(test_graph, source=0, sink=5))






"""simple docstring"""





import argparse

import intel_extension_for_pytorch as ipex
import torch

from diffusers import DPMSolverMultistepScheduler, StableDiffusionPipeline


__lowerCAmelCase       :					Optional[int]      					=					argparse.ArgumentParser('''Stable Diffusion script with intel optimization''', add_help=False)
parser.add_argument('''--dpm''', action='''store_true''', help='''Enable DPMSolver or not''')
parser.add_argument('''--steps''', default=None, type=int, help='''Num inference steps''')
__lowerCAmelCase       :					Optional[Any]      					=					parser.parse_args()


__lowerCAmelCase       :					Dict      					=					'''cpu'''
__lowerCAmelCase       :					Optional[Any]      					=					'''a lovely <dicoo> in red dress and hat, in the snowly and brightly night, with many brighly buildings'''

__lowerCAmelCase       :					Tuple      					=					'''path-to-your-trained-model'''
__lowerCAmelCase       :					List[Any]      					=					StableDiffusionPipeline.from_pretrained(model_id)
if args.dpm:
					__lowerCAmelCase       :					Optional[int]      					=					DPMSolverMultistepScheduler.from_config(pipe.scheduler.config)
__lowerCAmelCase       :					List[Any]      					=					pipe.to(device)

# to channels last
__lowerCAmelCase       :					Optional[Any]      					=					pipe.unet.to(memory_format=torch.channels_last)
__lowerCAmelCase       :					List[str]      					=					pipe.vae.to(memory_format=torch.channels_last)
__lowerCAmelCase       :					Optional[Any]      					=					pipe.text_encoder.to(memory_format=torch.channels_last)
if pipe.requires_safety_checker:
					__lowerCAmelCase       :					Dict      					=					pipe.safety_checker.to(memory_format=torch.channels_last)

# optimize with ipex
__lowerCAmelCase       :					Tuple      					=					torch.randn(2, 4, 64, 64)
__lowerCAmelCase       :					Any      					=					torch.rand(1) * 999
__lowerCAmelCase       :					List[str]      					=					torch.randn(2, 77, 768)
__lowerCAmelCase       :					Optional[int]      					=					(sample, timestep, encoder_hidden_status)
try:
					__lowerCAmelCase       :					List[Any]      					=					ipex.optimize(pipe.unet.eval(), dtype=torch.bfloataa, inplace=True, sample_input=input_example)
except Exception:
					__lowerCAmelCase       :					Optional[Any]      					=					ipex.optimize(pipe.unet.eval(), dtype=torch.bfloataa, inplace=True)
__lowerCAmelCase       :					Any      					=					ipex.optimize(pipe.vae.eval(), dtype=torch.bfloataa, inplace=True)
__lowerCAmelCase       :					int      					=					ipex.optimize(pipe.text_encoder.eval(), dtype=torch.bfloataa, inplace=True)
if pipe.requires_safety_checker:
					__lowerCAmelCase       :					Union[str, Any]      					=					ipex.optimize(pipe.safety_checker.eval(), dtype=torch.bfloataa, inplace=True)

# compute
__lowerCAmelCase       :					List[str]      					=					666
__lowerCAmelCase       :					Optional[int]      					=					torch.Generator(device).manual_seed(seed)
__lowerCAmelCase       :					List[Any]      					=					{'''generator''': generator}
if args.steps is not None:
					__lowerCAmelCase       :					Any      					=					args.steps

with torch.cpu.amp.autocast(enabled=True, dtype=torch.bfloataa):
					__lowerCAmelCase       :					str      					=					pipe(prompt, **generate_kwargs).images[0]

# save image
image.save('''generated.png''')

