


'''simple docstring'''
import unittest

from diffusers.models.unet_ad_blocks import *  # noqa F403
from diffusers.utils import torch_device

from .test_unet_blocks_common import UNetBlockTesterMixin




class 						_lowerCamelCase					(    snake_case_    ,		unittest.TestCase				):




 '''simple docstring'''
 __lowercase				:		str    							=						DownBlockaD  # noqa F405
 __lowercase				:		int    							=						'''down'''


 def  snake_case__   (      self						):

  """simple docstring"""







  __A  :		List[Any]       =			[-0.0_2_3_2, -0.9_8_6_9, 0.8_0_5_4, -0.0_6_3_7, -0.1_6_8_8, -1.4_2_6_4, 0.4_4_7_0, -1.3_3_9_4, 0.0_9_0_4]
  super().test_output(_UpperCAmelCase						)




class 						_lowerCamelCase					(    snake_case_    ,		unittest.TestCase				):




 '''simple docstring'''
 __lowercase				:		List[str]    							=						ResnetDownsampleBlockaD  # noqa F405
 __lowercase				:		Tuple    							=						'''down'''


 def  snake_case__   (      self						):

  """simple docstring"""







  __A  :		int       =			[0.0_7_1_0, 0.2_4_1_0, -0.7_3_2_0, -1.0_7_5_7, -1.1_3_4_3, 0.3_5_4_0, -0.0_1_3_3, -0.2_5_7_6, 0.0_9_4_8]
  super().test_output(_UpperCAmelCase						)




class 						_lowerCamelCase					(    snake_case_    ,		unittest.TestCase				):




 '''simple docstring'''
 __lowercase				:		Union[str, Any]    							=						AttnDownBlockaD  # noqa F405
 __lowercase				:		Tuple    							=						'''down'''


 def  snake_case__   (      self						):

  """simple docstring"""







  __A  :		Any       =			[0.0_6_3_6, 0.8_9_6_4, -0.6_2_3_4, -1.0_1_3_1, 0.0_8_4_4, 0.4_9_3_5, 0.3_4_3_7, 0.0_9_1_1, -0.2_9_5_7]
  super().test_output(_UpperCAmelCase						)




class 						_lowerCamelCase					(    snake_case_    ,		unittest.TestCase				):




 '''simple docstring'''
 __lowercase				:		Tuple    							=						CrossAttnDownBlockaD  # noqa F405
 __lowercase				:		Any    							=						'''down'''


 def  snake_case__   (      self						):

  """simple docstring"""







  __A     ,__A  :		Union[str, Any]       =			super().prepare_init_args_and_inputs_for_common()
  __A  :		str       =			32
  return init_dict, inputs_dict







 def  snake_case__   (      self						):

  """simple docstring"""







  __A  :		int       =			[0.2_2_3_8, -0.7_3_9_6, -0.2_2_5_5, -0.3_8_2_9, 0.1_9_2_5, 1.1_6_6_5, 0.0_6_0_3, -0.7_2_9_5, 0.1_9_8_3]
  super().test_output(_UpperCAmelCase						)




class 						_lowerCamelCase					(    snake_case_    ,		unittest.TestCase				):




 '''simple docstring'''
 __lowercase				:		Union[str, Any]    							=						SimpleCrossAttnDownBlockaD  # noqa F405
 __lowercase				:		Optional[Any]    							=						'''down'''


 @property
 def  snake_case__   (      self						):

  """simple docstring"""







  return super().get_dummy_input(include_encoder_hidden_states=_UpperCAmelCase						)


 def  snake_case__   (      self						):

  """simple docstring"""







  __A     ,__A  :		Optional[Any]       =			super().prepare_init_args_and_inputs_for_common()
  __A  :		List[str]       =			32
  return init_dict, inputs_dict







 @unittest.skipIf(torch_device == 'mps'      ,      'MPS result is not consistent'						)
 def  snake_case__   (      self						):

  """simple docstring"""







  __A  :		Dict       =			[0.7_9_2_1, -0.0_9_9_2, -0.1_9_6_2, -0.7_6_9_5, -0.4_2_4_2, 0.7_8_0_4, 0.4_7_3_7, 0.2_7_6_5, 0.3_3_3_8]
  super().test_output(_UpperCAmelCase						)




class 						_lowerCamelCase					(    snake_case_    ,		unittest.TestCase				):




 '''simple docstring'''
 __lowercase				:		Dict    							=						SkipDownBlockaD  # noqa F405
 __lowercase				:		Union[str, Any]    							=						'''down'''


 @property
 def  snake_case__   (      self						):

  """simple docstring"""







  return super().get_dummy_input(include_skip_sample=_UpperCAmelCase						)







 def  snake_case__   (      self						):

  """simple docstring"""







  __A  :		Dict       =			[-0.0_8_4_5, -0.2_0_8_7, -0.2_4_6_5, 0.0_9_7_1, 0.1_9_0_0, -0.0_4_8_4, 0.2_6_6_4, 0.4_1_7_9, 0.5_0_6_9]
  super().test_output(_UpperCAmelCase						)




class 						_lowerCamelCase					(    snake_case_    ,		unittest.TestCase				):




 '''simple docstring'''
 __lowercase				:		Tuple    							=						AttnSkipDownBlockaD  # noqa F405
 __lowercase				:		Union[str, Any]    							=						'''down'''


 @property
 def  snake_case__   (      self						):

  """simple docstring"""







  return super().get_dummy_input(include_skip_sample=_UpperCAmelCase						)







 def  snake_case__   (      self						):

  """simple docstring"""







  __A  :		Tuple       =			[0.5_5_3_9, 0.1_6_0_9, 0.4_9_2_4, 0.0_5_3_7, -0.1_9_9_5, 0.4_0_5_0, 0.0_9_7_9, -0.2_7_2_1, -0.0_6_4_2]
  super().test_output(_UpperCAmelCase						)




class 						_lowerCamelCase					(    snake_case_    ,		unittest.TestCase				):




 '''simple docstring'''
 __lowercase				:		Optional[int]    							=						DownEncoderBlockaD  # noqa F405
 __lowercase				:		int    							=						'''down'''


 @property
 def  snake_case__   (      self						):

  """simple docstring"""







  return super().get_dummy_input(include_temb=_UpperCAmelCase						)


 def  snake_case__   (      self						):

  """simple docstring"""







  __A  :		Dict       =			{
      'in_channels': 32,
      'out_channels': 32,
  }
  __A  :		List[str]       =			self.dummy_input
  return init_dict, inputs_dict







 def  snake_case__   (      self						):

  """simple docstring"""







  __A  :		int       =			[1.1_1_0_2, 0.5_3_0_2, 0.4_8_7_2, -0.0_0_2_3, -0.8_0_4_2, 0.0_4_8_3, -0.3_4_8_9, -0.5_6_3_2, 0.7_6_2_6]
  super().test_output(_UpperCAmelCase						)




class 						_lowerCamelCase					(    snake_case_    ,		unittest.TestCase				):




 '''simple docstring'''
 __lowercase				:		Optional[Any]    							=						AttnDownEncoderBlockaD  # noqa F405
 __lowercase				:		Optional[Any]    							=						'''down'''


 @property
 def  snake_case__   (      self						):

  """simple docstring"""







  return super().get_dummy_input(include_temb=_UpperCAmelCase						)


 def  snake_case__   (      self						):

  """simple docstring"""







  __A  :		Any       =			{
      'in_channels': 32,
      'out_channels': 32,
  }
  __A  :		Optional[Any]       =			self.dummy_input
  return init_dict, inputs_dict







 def  snake_case__   (      self						):

  """simple docstring"""







  __A  :		int       =			[0.8_9_6_6, -0.1_4_8_6, 0.8_5_6_8, 0.8_1_4_1, -0.9_0_4_6, -0.1_3_4_2, -0.0_9_7_2, -0.7_4_1_7, 0.1_5_3_8]
  super().test_output(_UpperCAmelCase						)




class 						_lowerCamelCase					(    snake_case_    ,		unittest.TestCase				):




 '''simple docstring'''
 __lowercase				:		List[Any]    							=						UNetMidBlockaD  # noqa F405
 __lowercase				:		Union[str, Any]    							=						'''mid'''


 def  snake_case__   (      self						):

  """simple docstring"""







  __A  :		List[Any]       =			{
      'in_channels': 32,
      'temb_channels': 128,
  }
  __A  :		List[Any]       =			self.dummy_input
  return init_dict, inputs_dict







 def  snake_case__   (      self						):

  """simple docstring"""







  __A  :		Optional[Any]       =			[-0.1_0_6_2, 1.7_2_4_8, 0.3_4_9_4, 1.4_5_6_9, -0.0_9_1_0, -1.2_4_2_1, -0.9_9_8_4, 0.6_7_3_6, 1.0_0_2_8]
  super().test_output(_UpperCAmelCase						)




class 						_lowerCamelCase					(    snake_case_    ,		unittest.TestCase				):




 '''simple docstring'''
 __lowercase				:		Optional[Any]    							=						UNetMidBlockaDCrossAttn  # noqa F405
 __lowercase				:		Tuple    							=						'''mid'''


 def  snake_case__   (      self						):

  """simple docstring"""







  __A     ,__A  :		List[Any]       =			super().prepare_init_args_and_inputs_for_common()
  __A  :		List[str]       =			32
  return init_dict, inputs_dict







 def  snake_case__   (      self						):

  """simple docstring"""







  __A  :		Dict       =			[0.0_1_8_7, 2.4_2_2_0, 0.4_4_8_4, 1.1_2_0_3, -0.6_1_2_1, -1.5_1_2_2, -0.8_2_7_0, 0.7_8_5_1, 1.8_3_3_5]
  super().test_output(_UpperCAmelCase						)




class 						_lowerCamelCase					(    snake_case_    ,		unittest.TestCase				):




 '''simple docstring'''
 __lowercase				:		str    							=						UNetMidBlockaDSimpleCrossAttn  # noqa F405
 __lowercase				:		int    							=						'''mid'''


 @property
 def  snake_case__   (      self						):

  """simple docstring"""







  return super().get_dummy_input(include_encoder_hidden_states=_UpperCAmelCase						)


 def  snake_case__   (      self						):

  """simple docstring"""







  __A     ,__A  :		Union[str, Any]       =			super().prepare_init_args_and_inputs_for_common()
  __A  :		int       =			32
  return init_dict, inputs_dict







 def  snake_case__   (      self						):

  """simple docstring"""







  __A  :		Any       =			[0.7_1_4_3, 1.9_9_7_4, 0.5_4_4_8, 1.3_9_7_7, 0.1_2_8_2, -1.1_2_3_7, -1.4_2_3_8, 0.5_5_3_0, 0.8_8_8_0]
  super().test_output(_UpperCAmelCase						)




class 						_lowerCamelCase					(    snake_case_    ,		unittest.TestCase				):




 '''simple docstring'''
 __lowercase				:		Optional[int]    							=						UpBlockaD  # noqa F405
 __lowercase				:		Optional[Any]    							=						'''up'''


 @property
 def  snake_case__   (      self						):

  """simple docstring"""







  return super().get_dummy_input(include_res_hidden_states_tuple=_UpperCAmelCase						)







 def  snake_case__   (      self						):

  """simple docstring"""







  __A  :		Optional[int]       =			[-0.2_0_4_1, -0.4_1_6_5, -0.3_0_2_2, 0.0_0_4_1, -0.6_6_2_8, -0.7_0_5_3, 0.1_9_2_8, -0.0_3_2_5, 0.0_5_2_3]
  super().test_output(_UpperCAmelCase						)




class 						_lowerCamelCase					(    snake_case_    ,		unittest.TestCase				):




 '''simple docstring'''
 __lowercase				:		Optional[Any]    							=						ResnetUpsampleBlockaD  # noqa F405
 __lowercase				:		Dict    							=						'''up'''


 @property
 def  snake_case__   (      self						):

  """simple docstring"""







  return super().get_dummy_input(include_res_hidden_states_tuple=_UpperCAmelCase						)







 def  snake_case__   (      self						):

  """simple docstring"""







  __A  :		List[Any]       =			[0.2_2_8_7, 0.3_5_4_9, -0.1_3_4_6, 0.4_7_9_7, -0.1_7_1_5, -0.9_6_4_9, 0.7_3_0_5, -0.5_8_6_4, -0.6_2_4_4]
  super().test_output(_UpperCAmelCase						)




class 						_lowerCamelCase					(    snake_case_    ,		unittest.TestCase				):




 '''simple docstring'''
 __lowercase				:		List[str]    							=						CrossAttnUpBlockaD  # noqa F405
 __lowercase				:		Dict    							=						'''up'''


 @property
 def  snake_case__   (      self						):

  """simple docstring"""







  return super().get_dummy_input(include_res_hidden_states_tuple=_UpperCAmelCase						)


 def  snake_case__   (      self						):

  """simple docstring"""







  __A     ,__A  :		Dict       =			super().prepare_init_args_and_inputs_for_common()
  __A  :		Optional[int]       =			32
  return init_dict, inputs_dict







 def  snake_case__   (      self						):

  """simple docstring"""







  __A  :		Optional[int]       =			[-0.1_4_0_3, -0.3_5_1_5, -0.0_4_2_0, -0.1_4_2_5, 0.3_1_6_7, 0.5_0_9_4, -0.2_1_8_1, 0.5_9_3_1, 0.5_5_8_2]
  super().test_output(_UpperCAmelCase						)




class 						_lowerCamelCase					(    snake_case_    ,		unittest.TestCase				):




 '''simple docstring'''
 __lowercase				:		Dict    							=						SimpleCrossAttnUpBlockaD  # noqa F405
 __lowercase				:		List[str]    							=						'''up'''


 @property
 def  snake_case__   (      self						):

  """simple docstring"""







  return super().get_dummy_input(include_res_hidden_states_tuple=_UpperCAmelCase      ,      include_encoder_hidden_states=_UpperCAmelCase						)


 def  snake_case__   (      self						):

  """simple docstring"""







  __A     ,__A  :		str       =			super().prepare_init_args_and_inputs_for_common()
  __A  :		str       =			32
  return init_dict, inputs_dict







 def  snake_case__   (      self						):

  """simple docstring"""







  __A  :		Union[str, Any]       =			[0.2_6_4_5, 0.1_4_8_0, 0.0_9_0_9, 0.8_0_4_4, -0.9_7_5_8, -0.9_0_8_3, 0.0_9_9_4, -1.1_4_5_3, -0.7_4_0_2]
  super().test_output(_UpperCAmelCase						)




class 						_lowerCamelCase					(    snake_case_    ,		unittest.TestCase				):




 '''simple docstring'''
 __lowercase				:		Optional[int]    							=						AttnUpBlockaD  # noqa F405
 __lowercase				:		Optional[int]    							=						'''up'''


 @property
 def  snake_case__   (      self						):

  """simple docstring"""







  return super().get_dummy_input(include_res_hidden_states_tuple=_UpperCAmelCase						)







 @unittest.skipIf(torch_device == 'mps'      ,      'MPS result is not consistent'						)
 def  snake_case__   (      self						):

  """simple docstring"""







  __A  :		Tuple       =			[0.0_9_7_9, 0.1_3_2_6, 0.0_0_2_1, 0.0_6_5_9, 0.2_2_4_9, 0.0_0_5_9, 0.1_1_3_2, 0.5_9_5_2, 0.1_0_3_3]
  super().test_output(_UpperCAmelCase						)




class 						_lowerCamelCase					(    snake_case_    ,		unittest.TestCase				):




 '''simple docstring'''
 __lowercase				:		Any    							=						SkipUpBlockaD  # noqa F405
 __lowercase				:		List[str]    							=						'''up'''


 @property
 def  snake_case__   (      self						):

  """simple docstring"""







  return super().get_dummy_input(include_res_hidden_states_tuple=_UpperCAmelCase						)







 def  snake_case__   (      self						):

  """simple docstring"""







  __A  :		Union[str, Any]       =			[-0.0_8_9_3, -0.1_2_3_4, -0.1_5_0_6, -0.0_3_3_2, 0.0_1_2_3, -0.0_2_1_1, 0.0_5_6_6, 0.0_1_4_3, 0.0_3_6_2]
  super().test_output(_UpperCAmelCase						)




class 						_lowerCamelCase					(    snake_case_    ,		unittest.TestCase				):




 '''simple docstring'''
 __lowercase				:		Any    							=						AttnSkipUpBlockaD  # noqa F405
 __lowercase				:		Optional[Any]    							=						'''up'''


 @property
 def  snake_case__   (      self						):

  """simple docstring"""







  return super().get_dummy_input(include_res_hidden_states_tuple=_UpperCAmelCase						)







 def  snake_case__   (      self						):

  """simple docstring"""







  __A  :		Union[str, Any]       =			[0.0_3_6_1, 0.0_6_1_7, 0.2_7_8_7, -0.0_3_5_0, 0.0_3_4_2, 0.3_4_2_1, -0.0_8_4_3, 0.0_9_1_3, 0.3_0_1_5]
  super().test_output(_UpperCAmelCase						)




class 						_lowerCamelCase					(    snake_case_    ,		unittest.TestCase				):




 '''simple docstring'''
 __lowercase				:		Optional[int]    							=						UpDecoderBlockaD  # noqa F405
 __lowercase				:		Any    							=						'''up'''


 @property
 def  snake_case__   (      self						):

  """simple docstring"""







  return super().get_dummy_input(include_temb=_UpperCAmelCase						)


 def  snake_case__   (      self						):

  """simple docstring"""







  __A  :		List[Any]       =			{'in_channels': 32, 'out_channels': 32}

  __A  :		int       =			self.dummy_input
  return init_dict, inputs_dict







 def  snake_case__   (      self						):

  """simple docstring"""







  __A  :		List[str]       =			[0.4_4_0_4, 0.1_9_9_8, -0.9_8_8_6, -0.3_3_2_0, -0.3_1_2_8, -0.7_0_3_4, -0.6_9_5_5, -0.2_3_3_8, -0.3_1_3_7]
  super().test_output(_UpperCAmelCase						)




class 						_lowerCamelCase					(    snake_case_    ,		unittest.TestCase				):




 '''simple docstring'''
 __lowercase				:		Dict    							=						AttnUpDecoderBlockaD  # noqa F405
 __lowercase				:		Optional[int]    							=						'''up'''


 @property
 def  snake_case__   (      self						):

  """simple docstring"""







  return super().get_dummy_input(include_temb=_UpperCAmelCase						)


 def  snake_case__   (      self						):

  """simple docstring"""







  __A  :		Tuple       =			{'in_channels': 32, 'out_channels': 32}

  __A  :		Any       =			self.dummy_input
  return init_dict, inputs_dict







 def  snake_case__   (      self						):

  """simple docstring"""







  __A  :		Optional[Any]       =			[0.6_7_3_8, 0.4_4_9_1, 0.1_0_5_5, 1.0_7_1_0, 0.7_3_1_6, 0.3_3_3_9, 0.3_3_5_2, 0.1_0_2_3, 0.3_5_6_8]
  super().test_output(_UpperCAmelCase						)










'''simple docstring'''
from __future__ import annotations

import math
import random
from collections.abc import Collection
from typing import overload

class 						_lowerCamelCase					:




 '''simple docstring'''


 def __init__(      self      ,      __lowercase = None						):

  """simple docstring"""







  if components is None:
   __A  :		Optional[int]       =			[]
  __A  :		Dict       =			list(__lowercase						)


 def __len__(      self						):

  """simple docstring"""







  return len(self.__components						)


 def __str__(      self						):

  """simple docstring"""







  return "(" + ",".join(map(__lowercase      ,      self.__components						)						) + ")"


 def __add__(      self      ,      __lowercase						):

  """simple docstring"""







  __A  :		Union[str, Any]       =			len(self						)
  if size == len(__lowercase						):
   __A  :		Dict       =			[self.__components[i] + other.component(__lowercase						) for i in range(__lowercase						)]
   return Vector(__lowercase						)
  else:
   raise Exception('must have the same size'						)


 def __sub__(      self      ,      __lowercase						):

  """simple docstring"""







  __A  :		int       =			len(self						)
  if size == len(__lowercase						):
   __A  :		str       =			[self.__components[i] - other.component(__lowercase						) for i in range(__lowercase						)]
   return Vector(__lowercase						)
  else:  # error case
   raise Exception('must have the same size'						)


 @overload
 def __mul__(      self      ,      __lowercase						):

  """simple docstring"""







  ...


 @overload
 def __mul__(      self      ,      __lowercase						):

  """simple docstring"""







  ...


 def __mul__(      self      ,      __lowercase						):

  """simple docstring"""







  if isinstance(__lowercase      ,      (float, int)						):
   __A  :		Dict       =			[c * other for c in self.__components]
   return Vector(__lowercase						)
  elif isinstance(__lowercase      ,      __lowercase						) and len(self						) == len(__lowercase						):
   __A  :		Optional[Any]       =			len(self						)
   __A  :		Optional[int]       =			[self.__components[i] * other.component(__lowercase						) for i in range(__lowercase						)]
   return sum(__lowercase						)
  else:  # error case
   raise Exception('invalid operand!'						)


 def  snake_case__   (      self						):

  """simple docstring"""







  return Vector(self.__components						)


 def  snake_case__   (      self      ,      __lowercase						):

  """simple docstring"""







  if isinstance(__lowercase      ,      __lowercase						) and -len(self.__components						) <= i < len(self.__components						):
   return self.__components[i]
  else:
   raise Exception('index out of range'						)


 def  snake_case__   (      self      ,      __lowercase      ,      __lowercase						):

  """simple docstring"""







  assert -len(self.__components						) <= pos < len(self.__components						)
  __A  :		str       =			value


 def  snake_case__   (      self						):

  """simple docstring"""







  if len(self.__components						) == 0:
   raise Exception('Vector is empty'						)
  __A  :		List[Any]       =			[c**2 for c in self.__components]
  return math.sqrt(sum(__lowercase						)						)







 def  snake_case__   (      self      ,      __lowercase      ,      __lowercase = False						):

  """simple docstring"""







  __A  :		List[Any]       =			self * other
  __A  :		Any       =			self.euclidean_length() * other.euclidean_length()
  if deg:
   return math.degrees(math.acos(num / den						)						)
  else:
   return math.acos(num / den						)


def 			_lowercase       (				UpperCamelCase__       :					int			):
 assert isinstance(UpperCamelCase__,				UpperCamelCase__			)
 return Vector([0] * dimension			)


def 			_lowercase       (				UpperCamelCase__       :					int,				UpperCamelCase__       :					int			):
 assert isinstance(UpperCamelCase__,				UpperCamelCase__			) and (isinstance(UpperCamelCase__,				UpperCamelCase__			))
 __A  :		List[str]       =			[0] * dimension
 __A  :		Tuple       =			1
 return Vector(UpperCamelCase__			)


def 			_lowercase       (				UpperCamelCase__       :					float,				UpperCamelCase__       :					Vector,				UpperCamelCase__       :					Vector			):
 assert (
     isinstance(UpperCamelCase__,				UpperCamelCase__			)
     and isinstance(UpperCamelCase__,				UpperCamelCase__			)
     and (isinstance(UpperCamelCase__,				(int, float)			))
 )
 return x * scalar + y


def 			_lowercase       (				UpperCamelCase__       :					int,				UpperCamelCase__       :					int,				UpperCamelCase__       :					int			):
 random.seed(UpperCamelCase__			)
 __A  :		Any       =			[random.randint(UpperCamelCase__,				UpperCamelCase__			) for _ in range(UpperCamelCase__			)]
 return Vector(UpperCamelCase__			)

class 						_lowerCamelCase					:




 '''simple docstring'''


 def __init__(      self      ,      __lowercase      ,      __lowercase      ,      __lowercase						):

  """simple docstring"""







  __A  :		str       =			matrix
  __A  :		str       =			w
  __A  :		Dict       =			h


 def __str__(      self						):

  """simple docstring"""







  __A  :		Tuple       =			''
  for i in range(self.__height						):
   ans += "|"
   for j in range(self.__width						):
    if j < self.__width - 1:
     ans += str(self.__matrix[i][j]						) + ","
    else:
     ans += str(self.__matrix[i][j]						) + "|\n"
  return ans


 def __add__(      self      ,      __lowercase						):

  """simple docstring"""







  if self.__width == other.width() and self.__height == other.height():
   __A  :		Union[str, Any]       =			[]
   for i in range(self.__height						):
    __A  :		List[Any]       =			[
        self.__matrix[i][j] + other.component(__lowercase      ,      __lowercase						)
        for j in range(self.__width						)
    ]
    matrix.append(__lowercase						)
   return Matrix(__lowercase      ,      self.__width      ,      self.__height						)
  else:
   raise Exception('matrix must have the same dimension!'						)


 def __sub__(      self      ,      __lowercase						):

  """simple docstring"""







  if self.__width == other.width() and self.__height == other.height():
   __A  :		Dict       =			[]
   for i in range(self.__height						):
    __A  :		str       =			[
        self.__matrix[i][j] - other.component(__lowercase      ,      __lowercase						)
        for j in range(self.__width						)
    ]
    matrix.append(__lowercase						)
   return Matrix(__lowercase      ,      self.__width      ,      self.__height						)
  else:
   raise Exception('matrices must have the same dimension!'						)


 @overload
 def __mul__(      self      ,      __lowercase						):

  """simple docstring"""







  ...


 @overload
 def __mul__(      self      ,      __lowercase						):

  """simple docstring"""







  ...


 def __mul__(      self      ,      __lowercase						):

  """simple docstring"""







  if isinstance(__lowercase      ,      __lowercase						):  # matrix-vector
   if len(__lowercase						) == self.__width:
    __A  :		Tuple       =			zero_vector(self.__height						)
    for i in range(self.__height						):
     __A  :		Any       =			[
         self.__matrix[i][j] * other.component(__lowercase						)
         for j in range(self.__width						)
     ]
     ans.change_component(__lowercase      ,      sum(__lowercase						)						)
    return ans
   else:
    raise Exception(
        'vector must have the same size as the '
        'number of columns of the matrix!'						)
  elif isinstance(__lowercase      ,      (int, float)						):  # matrix-scalar
   __A  :		Optional[Any]       =			[
       [self.__matrix[i][j] * other for j in range(self.__width						)]
       for i in range(self.__height						)
   ]
   return Matrix(__lowercase      ,      self.__width      ,      self.__height						)
  return None


 def  snake_case__   (      self						):

  """simple docstring"""







  return self.__height


 def  snake_case__   (      self						):

  """simple docstring"""







  return self.__width


 def  snake_case__   (      self      ,      __lowercase      ,      __lowercase						):

  """simple docstring"""







  if 0 <= x < self.__height and 0 <= y < self.__width:
   return self.__matrix[x][y]
  else:
   raise Exception('change_component: indices out of bounds'						)


 def  snake_case__   (      self      ,      __lowercase      ,      __lowercase      ,      __lowercase						):

  """simple docstring"""







  if 0 <= x < self.__height and 0 <= y < self.__width:
   __A  :		Dict       =			value
  else:
   raise Exception('change_component: indices out of bounds'						)


 def  snake_case__   (      self      ,      __lowercase      ,      __lowercase						):

  """simple docstring"""







  if self.__height != self.__width:
   raise Exception('Matrix is not square'						)
  __A  :		Union[str, Any]       =			self.__matrix[:x] + self.__matrix[x + 1 :]
  for i in range(len(__lowercase						)						):
   __A  :		Dict       =			minor[i][:y] + minor[i][y + 1 :]
  return Matrix(__lowercase      ,      self.__width - 1      ,      self.__height - 1						).determinant()


 def  snake_case__   (      self      ,      __lowercase      ,      __lowercase						):

  """simple docstring"""







  if self.__height != self.__width:
   raise Exception('Matrix is not square'						)
  if 0 <= x < self.__height and 0 <= y < self.__width:
   return (-1) ** (x + y) * self.minor(__lowercase      ,      __lowercase						)
  else:
   raise Exception('Indices out of bounds'						)







 def  snake_case__   (      self						):

  """simple docstring"""







  if self.__height != self.__width:
   raise Exception('Matrix is not square'						)
  if self.__height < 1:
   raise Exception('Matrix has no element'						)
  elif self.__height == 1:
   return self.__matrix[0][0]
  elif self.__height == 2:
   return (
       self.__matrix[0][0] * self.__matrix[1][1]
       - self.__matrix[0][1] * self.__matrix[1][0]
   )
  else:
   __A  :		List[str]       =			[
       self.__matrix[0][y] * self.cofactor(0      ,      __lowercase						) for y in range(self.__width						)
   ]
   return sum(__lowercase						)


def 			_lowercase       (				UpperCamelCase__       :					int			):
 __A  :		list[list[float]]       =			[[0] * n for _ in range(UpperCamelCase__			)]
 return Matrix(UpperCamelCase__,				UpperCamelCase__,				UpperCamelCase__			)


def 			_lowercase       (				UpperCamelCase__       :					int,				UpperCamelCase__       :					int,				UpperCamelCase__       :					int,				UpperCamelCase__       :					int			):
 random.seed(UpperCamelCase__			)
 __A  :		list[list[float]]       =			[
     [random.randint(UpperCamelCase__,				UpperCamelCase__			) for _ in range(UpperCamelCase__			)] for _ in range(UpperCamelCase__			)
 ]
 return Matrix(UpperCamelCase__,				UpperCamelCase__,				UpperCamelCase__			)






