


"""simple docstring"""







from __future__ import annotations

import math
import random
from typing import Any




class 				UpperCamelCase_			:

	"""simple docstring"""





	def __init__(				self    :       Any     ) ->			None:
						__SCREAMING_SNAKE_CASE		     =       []
						__SCREAMING_SNAKE_CASE		     =       0
						__SCREAMING_SNAKE_CASE		     =       0




	def 						UpperCAmelCase_   (				self    :       List[str]     ) ->			bool:
						return self.head == self.tail




	def 						UpperCAmelCase_   (				self    :       List[str]    ,    UpperCAmelCase__    :       Any     ) ->			None:
						self.data.append(UpperCAmelCase__     )
						__SCREAMING_SNAKE_CASE		     =       self.tail + 1




	def 						UpperCAmelCase_   (				self    :       Any     ) ->			Any:
						__SCREAMING_SNAKE_CASE		     =       self.data[self.head]
						__SCREAMING_SNAKE_CASE		     =       self.head + 1
						return ret




	def 						UpperCAmelCase_   (				self    :       Dict     ) ->			int:
						return self.tail - self.head




	def 						UpperCAmelCase_   (				self    :       int     ) ->			None:
						print(self.data     )
						print("**************"     )
						print(self.data[self.head : self.tail]     )




class 				UpperCamelCase_			:

	"""simple docstring"""





	def __init__(				self    :       int    ,    UpperCAmelCase__    :       Any     ) ->			None:
						__SCREAMING_SNAKE_CASE		     =       data
						__SCREAMING_SNAKE_CASE		     =       None
						__SCREAMING_SNAKE_CASE		     =       None
						__SCREAMING_SNAKE_CASE		     =       1




	def 						UpperCAmelCase_   (				self    :       Optional[Any]     ) ->			Any:
						return self.data




	def 						UpperCAmelCase_   (				self    :       List[str]     ) ->			MyNode | None:
						return self.left




	def 						UpperCAmelCase_   (				self    :       Dict     ) ->			MyNode | None:
						return self.right




	def 						UpperCAmelCase_   (				self    :       Tuple     ) ->			int:
						return self.height




	def 						UpperCAmelCase_   (				self    :       int    ,    UpperCAmelCase__    :       Any     ) ->			None:
						__SCREAMING_SNAKE_CASE		     =       data




	def 						UpperCAmelCase_   (				self    :       Tuple    ,    UpperCAmelCase__    :       MyNode | None     ) ->			None:
						__SCREAMING_SNAKE_CASE		     =       node




	def 						UpperCAmelCase_   (				self    :       str    ,    UpperCAmelCase__    :       MyNode | None     ) ->			None:
						__SCREAMING_SNAKE_CASE		     =       node




	def 						UpperCAmelCase_   (				self    :       Union[str, Any]    ,    UpperCAmelCase__    :       int     ) ->			None:
						__SCREAMING_SNAKE_CASE		     =       height




def      UpperCAmelCase__ (lowerCAmelCase_     ):




					'''simple docstring'''


					if node is None:
										return 0
					return node.get_height()




def      UpperCAmelCase__ (lowerCAmelCase_						,		lowerCAmelCase_     ):




					'''simple docstring'''


					if a > b:
										return a
					return b




def      UpperCAmelCase__ (lowerCAmelCase_     ):




					'''simple docstring'''


					print("left rotation node:"						,		node.get_data()     )
					__SCREAMING_SNAKE_CASE		     =       node.get_left()
					assert ret is not None
					node.set_left(ret.get_right()     )
					ret.set_right(lowerCAmelCase_     )
					__SCREAMING_SNAKE_CASE		     =       my_max(get_height(node.get_right()     )						,		get_height(node.get_left()     )     ) + 1
					node.set_height(lowerCAmelCase_     )
					__SCREAMING_SNAKE_CASE		     =       my_max(get_height(ret.get_right()     )						,		get_height(ret.get_left()     )     ) + 1
					ret.set_height(lowerCAmelCase_     )
					return ret




def      UpperCAmelCase__ (lowerCAmelCase_     ):




					'''simple docstring'''


					print("right rotation node:"						,		node.get_data()     )
					__SCREAMING_SNAKE_CASE		     =       node.get_right()
					assert ret is not None
					node.set_right(ret.get_left()     )
					ret.set_left(lowerCAmelCase_     )
					__SCREAMING_SNAKE_CASE		     =       my_max(get_height(node.get_right()     )						,		get_height(node.get_left()     )     ) + 1
					node.set_height(lowerCAmelCase_     )
					__SCREAMING_SNAKE_CASE		     =       my_max(get_height(ret.get_right()     )						,		get_height(ret.get_left()     )     ) + 1
					ret.set_height(lowerCAmelCase_     )
					return ret




def      UpperCAmelCase__ (lowerCAmelCase_     ):




					'''simple docstring'''


					__SCREAMING_SNAKE_CASE		     =       node.get_left()
					assert left_child is not None
					node.set_left(left_rotation(lowerCAmelCase_     )     )
					return right_rotation(lowerCAmelCase_     )




def      UpperCAmelCase__ (lowerCAmelCase_     ):




					'''simple docstring'''


					__SCREAMING_SNAKE_CASE		     =       node.get_right()
					assert right_child is not None
					node.set_right(right_rotation(lowerCAmelCase_     )     )
					return left_rotation(lowerCAmelCase_     )




def      UpperCAmelCase__ (lowerCAmelCase_						,		lowerCAmelCase_     ):




					'''simple docstring'''


					if node is None:
										return MyNode(lowerCAmelCase_     )
					if data < node.get_data():
										node.set_left(insert_node(node.get_left()						,		lowerCAmelCase_     )     )
										if (
										    get_height(node.get_left()     ) - get_height(node.get_right()     ) == 2
										):  # an unbalance detected
															__SCREAMING_SNAKE_CASE		     =       node.get_left()
															assert left_child is not None
															if (
															    data < left_child.get_data()
															):  # new node is the left child of the left child
																				__SCREAMING_SNAKE_CASE		     =       right_rotation(lowerCAmelCase_     )
															else:
																				__SCREAMING_SNAKE_CASE		     =       lr_rotation(lowerCAmelCase_     )
					else:
										node.set_right(insert_node(node.get_right()						,		lowerCAmelCase_     )     )
										if get_height(node.get_right()     ) - get_height(node.get_left()     ) == 2:
															__SCREAMING_SNAKE_CASE		     =       node.get_right()
															assert right_child is not None
															if data < right_child.get_data():
																				__SCREAMING_SNAKE_CASE		     =       rl_rotation(lowerCAmelCase_     )
															else:
																				__SCREAMING_SNAKE_CASE		     =       left_rotation(lowerCAmelCase_     )
					__SCREAMING_SNAKE_CASE		     =       my_max(get_height(node.get_right()     )						,		get_height(node.get_left()     )     ) + 1
					node.set_height(lowerCAmelCase_     )
					return node




def      UpperCAmelCase__ (lowerCAmelCase_     ):




					'''simple docstring'''


					while True:
										__SCREAMING_SNAKE_CASE		     =       root.get_right()
										if right_child is None:
															break
										__SCREAMING_SNAKE_CASE		     =       right_child
					return root.get_data()




def      UpperCAmelCase__ (lowerCAmelCase_     ):




					'''simple docstring'''


					while True:
										__SCREAMING_SNAKE_CASE		     =       root.get_left()
										if left_child is None:
															break
										__SCREAMING_SNAKE_CASE		     =       left_child
					return root.get_data()




def      UpperCAmelCase__ (lowerCAmelCase_						,		lowerCAmelCase_     ):




					'''simple docstring'''


					__SCREAMING_SNAKE_CASE		     =       root.get_left()
					__SCREAMING_SNAKE_CASE		     =       root.get_right()
					if root.get_data() == data:
										if left_child is not None and right_child is not None:
															__SCREAMING_SNAKE_CASE		     =       get_left_most(lowerCAmelCase_     )
															root.set_data(lowerCAmelCase_     )
															root.set_right(del_node(lowerCAmelCase_						,		lowerCAmelCase_     )     )
										elif left_child is not None:
															__SCREAMING_SNAKE_CASE		     =       left_child
										elif right_child is not None:
															__SCREAMING_SNAKE_CASE		     =       right_child
										else:
															return None
					elif root.get_data() > data:
										if left_child is None:
															print("No such data"     )
															return root
										else:
															root.set_left(del_node(lowerCAmelCase_						,		lowerCAmelCase_     )     )
					else:  # root.get_data() < data
										if right_child is None:
															return root
										else:
															root.set_right(del_node(lowerCAmelCase_						,		lowerCAmelCase_     )     )

					if get_height(lowerCAmelCase_     ) - get_height(lowerCAmelCase_     ) == 2:
										assert right_child is not None
										if get_height(right_child.get_right()     ) > get_height(right_child.get_left()     ):
															__SCREAMING_SNAKE_CASE		     =       left_rotation(lowerCAmelCase_     )
										else:
															__SCREAMING_SNAKE_CASE		     =       rl_rotation(lowerCAmelCase_     )
					elif get_height(lowerCAmelCase_     ) - get_height(lowerCAmelCase_     ) == -2:
										assert left_child is not None
										if get_height(left_child.get_left()     ) > get_height(left_child.get_right()     ):
															__SCREAMING_SNAKE_CASE		     =       right_rotation(lowerCAmelCase_     )
										else:
															__SCREAMING_SNAKE_CASE		     =       lr_rotation(lowerCAmelCase_     )
					__SCREAMING_SNAKE_CASE		     =       my_max(get_height(root.get_right()     )						,		get_height(root.get_left()     )     ) + 1
					root.set_height(lowerCAmelCase_     )
					return root




class 				UpperCamelCase_			:

	"""simple docstring"""





	def __init__(				self    :       List[str]     ) ->			None:
						__SCREAMING_SNAKE_CASE		     =       None




	def 						UpperCAmelCase_   (				self    :       Union[str, Any]     ) ->			int:
						return get_height(self.root     )




	def 						UpperCAmelCase_   (				self    :       List[Any]    ,    UpperCAmelCase__    :       Any     ) ->			None:
						print("insert:" + str(UpperCAmelCase__     )     )
						__SCREAMING_SNAKE_CASE		     =       insert_node(self.root    ,    UpperCAmelCase__     )




	def 						UpperCAmelCase_   (				self    :       Any    ,    UpperCAmelCase__    :       Any     ) ->			None:
						print("delete:" + str(UpperCAmelCase__     )     )
						if self.root is None:
											print("Tree is empty!"     )
											return
						__SCREAMING_SNAKE_CASE		     =       del_node(self.root    ,    UpperCAmelCase__     )




	def __str__(				self    :       List[str]    ,    ) ->			str:  # a level traversale, gives a more intuitive look on the tree
						__SCREAMING_SNAKE_CASE		     =       ""
						__SCREAMING_SNAKE_CASE		     =       MyQueue()
						q.push(self.root     )
						__SCREAMING_SNAKE_CASE		     =       self.get_height()
						if layer == 0:
											return output
						__SCREAMING_SNAKE_CASE		     =       0
						while not q.is_empty():
											__SCREAMING_SNAKE_CASE		     =       q.pop()
											__SCREAMING_SNAKE_CASE		     =       " " * int(math.pow(2    ,    layer - 1     )     )
											output += space
											if node is None:
																output += "*"
																q.push(UpperCAmelCase__     )
																q.push(UpperCAmelCase__     )
											else:
																output += str(node.get_data()     )
																q.push(node.get_left()     )
																q.push(node.get_right()     )
											output += space
											__SCREAMING_SNAKE_CASE		     =       cnt + 1
											for i in range(1_0_0     ):
																if cnt == math.pow(2    ,    UpperCAmelCase__     ) - 1:
																					__SCREAMING_SNAKE_CASE		     =       layer - 1
																					if layer == 0:
																										output += "\n*************************************"
																										return output
																					output += "\n"
																					break
						output += "\n*************************************"
						return output




def      UpperCAmelCase__ ():




					'''simple docstring'''


					import doctest

					doctest.testmod()


if __name__ == "__main__":
		_test()
		a__       :							List[Any]        =  AVLtree()
		a__       :							Dict        =  list(range(1_0))
		random.shuffle(lst)
		for i in lst:
				t.insert(i)
				print(str(t))
		random.shuffle(lst)
		for i in lst:
				t.del_node(i)
				print(str(t))




"""simple docstring"""







import platform
from argparse import ArgumentParser

import huggingface_hub

from .. import __version__ as version
from ..utils import is_accelerate_available, is_torch_available, is_transformers_available, is_xformers_available
from . import BaseDiffusersCLICommand




def      UpperCAmelCase__ (lowerCAmelCase_     ):




					'''simple docstring'''


					return EnvironmentCommand()




class 				UpperCamelCase_			(				UpperCamelCase):

	"""simple docstring"""





	@staticmethod
	def 						UpperCAmelCase_   (				UpperCAmelCase__    :       ArgumentParser     ) ->			Optional[Any]:
						__SCREAMING_SNAKE_CASE		     =       parser.add_parser("env"     )
						download_parser.set_defaults(func=UpperCAmelCase__     )




	def 						UpperCAmelCase_   (				self    :       List[Any]     ) ->			List[str]:
						__SCREAMING_SNAKE_CASE		     =       huggingface_hub.__version__

						__SCREAMING_SNAKE_CASE		     =       "not installed"
						__SCREAMING_SNAKE_CASE		     =       "NA"
						if is_torch_available():
											import torch

											__SCREAMING_SNAKE_CASE		     =       torch.__version__
											__SCREAMING_SNAKE_CASE		     =       torch.cuda.is_available()

						__SCREAMING_SNAKE_CASE		     =       "not installed"
						if is_transformers_available():
											import transformers

											__SCREAMING_SNAKE_CASE		     =       transformers.__version__

						__SCREAMING_SNAKE_CASE		     =       "not installed"
						if is_accelerate_available():
											import accelerate

											__SCREAMING_SNAKE_CASE		     =       accelerate.__version__

						__SCREAMING_SNAKE_CASE		     =       "not installed"
						if is_xformers_available():
											import xformers

											__SCREAMING_SNAKE_CASE		     =       xformers.__version__

						__SCREAMING_SNAKE_CASE		     =       {
						    "`diffusers` version": version,
						    "Platform": platform.platform(),
						    "Python version": platform.python_version(),
						    "PyTorch version (GPU?)": F"""{pt_version} ({pt_cuda_available})""",
						    "Huggingface_hub version": hub_version,
						    "Transformers version": transformers_version,
						    "Accelerate version": accelerate_version,
						    "xFormers version": xformers_version,
						    "Using GPU in script?": "<fill in>",
						    "Using distributed or parallel set-up in script?": "<fill in>",
						}

						print("\nCopy-and-paste the text below in your GitHub issue and FILL OUT the two last points.\n"     )
						print(self.format_dict(UpperCAmelCase__     )     )

						return info




	@staticmethod
	def 						UpperCAmelCase_   (				UpperCAmelCase__    :       Optional[Any]     ) ->			str:
						return "\n".join([F"""- {prop}: {val}""" for prop, val in d.items()]     ) + "\n"
