from typing import Optional, Tuple, Union

import flax
import flax.linen as nn
import jax
import jax.numpy as jnp
from flax.core.frozen_dict import FrozenDict

from ..configuration_utils import ConfigMixin, flax_register_to_config
from ..utils import BaseOutput
from .embeddings_flax import FlaxTimestepEmbedding, FlaxTimesteps
from .modeling_flax_utils import FlaxModelMixin
from .unet_ad_blocks_flax import (
    FlaxCrossAttnDownBlockaD,
    FlaxDownBlockaD,
    FlaxUNetMidBlockaDCrossAttn,
)



@flax.struct.dataclass
class  _lowerCamelCase			(__lowerCamelCase     ):
				_snake_case     =  42
				_snake_case     =  42



class  _lowerCamelCase			(nn.Module     ):
				_snake_case     =  42
				_snake_case     =  (16, 32, 96, 256)
				_snake_case     =  jnp.floataa







				def 							__UpperCAmelCase					( self    :       List[Any]						):

					"""simple docstring"""






					_lowercase :    Tuple							=							nn.Conv(
					    self.block_out_channels[0]			,					kernel_size=(3, 3)			,					padding=((1, 1), (1, 1))			,					dtype=self.dtype			,					)

					_lowercase :    Dict							=							[]
					for i in range(len(self.block_out_channels						) - 1						):
						_lowercase :    str							=							self.block_out_channels[i]
						_lowercase :    Optional[Any]							=							self.block_out_channels[i + 1]
						_lowercase :    int							=							nn.Conv(
						    lowerCamelCase_			,					kernel_size=(3, 3)			,					padding=((1, 1), (1, 1))			,					dtype=self.dtype			,					)
						blocks.append(lowerCamelCase_						)
						_lowercase :    List[str]							=							nn.Conv(
						    lowerCamelCase_			,					kernel_size=(3, 3)			,					strides=(2, 2)			,					padding=((1, 1), (1, 1))			,					dtype=self.dtype			,					)
						blocks.append(lowerCamelCase_						)
					_lowercase :    str							=							blocks

					_lowercase :    List[str]							=							nn.Conv(
					    self.conditioning_embedding_channels			,					kernel_size=(3, 3)			,					padding=((1, 1), (1, 1))			,					kernel_init=nn.initializers.zeros_init()			,					bias_init=nn.initializers.zeros_init()			,					dtype=self.dtype			,					)







				def __call__( self    :       int			,					lowerCamelCase_    :       int						):

					"""simple docstring"""






					_lowercase :    int							=							self.conv_in(lowerCamelCase_						)
					_lowercase :    Optional[Any]							=							nn.silu(lowerCamelCase_						)

					for block in self.blocks:
						_lowercase :    Optional[int]							=							block(lowerCamelCase_						)
						_lowercase :    List[str]							=							nn.silu(lowerCamelCase_						)

					_lowercase :    List[str]							=							self.conv_out(lowerCamelCase_						)

					return embedding



@flax_register_to_config
class  _lowerCamelCase			(nn.Module						,							__lowerCamelCase						,							__lowerCamelCase     ):
				_snake_case     =  32
				_snake_case     =  4
				_snake_case     =  (
				    "CrossAttnDownBlock2D",
				    "CrossAttnDownBlock2D",
				    "CrossAttnDownBlock2D",
				    "DownBlock2D",
				)
				_snake_case     =  False
				_snake_case     =  (320, 640, 1_280, 1_280)
				_snake_case     =  2
				_snake_case     =  8
				_snake_case     =  None
				_snake_case     =  1_280
				_snake_case     =  0.0
				_snake_case     =  False
				_snake_case     =  jnp.floataa
				_snake_case     =  True
				_snake_case     =  0
				_snake_case     =  "rgb"
				_snake_case     =  (16, 32, 96, 256)







				def 							__UpperCAmelCase					( self    :       Any			,					lowerCamelCase_    :       jax.random.KeyArray						):

					"""simple docstring"""






					_lowercase :    Any							=							(1, self.in_channels, self.sample_size, self.sample_size)
					_lowercase :    int							=							jnp.zeros(lowerCamelCase_			,					dtype=jnp.floataa						)
					_lowercase :    Optional[Any]							=							jnp.ones((1,)			,					dtype=jnp.intaa						)
					_lowercase :    Tuple							=							jnp.zeros((1, 1, self.cross_attention_dim)			,					dtype=jnp.floataa						)
					_lowercase :    Tuple							=							(1, 3, self.sample_size * 8, self.sample_size * 8)
					_lowercase :    Optional[Any]							=							jnp.zeros(lowerCamelCase_			,					dtype=jnp.floataa						)

					_lowercase :    Any							=							jax.random.split(lowerCamelCase_						)
					_lowercase :    str							=							{'params': params_rng, 'dropout': dropout_rng}

					return self.init(lowerCamelCase_			,					lowerCamelCase_			,					lowerCamelCase_			,					lowerCamelCase_			,					lowerCamelCase_						)["params"]







				def 							__UpperCAmelCase					( self    :       List[Any]						):

					"""simple docstring"""






					_lowercase :    Dict							=							self.block_out_channels
					_lowercase :    Optional[Any]							=							block_out_channels[0] * 4

					# If `num_attention_heads` is not defined (which is the case for most models)
					# it will default to `attention_head_dim`. This looks weird upon first reading it and it is.
					# The reason for this behavior is to correct for incorrectly named variables that were introduced
					# when this library was created. The incorrect naming was only discovered much later in https://github.com/huggingface/diffusers/issues/2011#issuecomment-1547958131
					# Changing `attention_head_dim` to `num_attention_heads` for 40,000+ configurations is too backwards breaking
					# which is why we correct for the naming here.
					_lowercase :    Optional[int]							=							self.num_attention_heads or self.attention_head_dim

					# input
					_lowercase :    int							=							nn.Conv(
					    block_out_channels[0]			,					kernel_size=(3, 3)			,					strides=(1, 1)			,					padding=((1, 1), (1, 1))			,					dtype=self.dtype			,					)

					# time
					_lowercase :    Tuple							=							FlaxTimesteps(
					    block_out_channels[0]			,					flip_sin_to_cos=self.flip_sin_to_cos			,					freq_shift=self.config.freq_shift						)
					_lowercase :    Any							=							FlaxTimestepEmbedding(lowerCamelCase_			,					dtype=self.dtype						)

					_lowercase :    Optional[int]							=							FlaxControlNetConditioningEmbedding(
					    conditioning_embedding_channels=block_out_channels[0]			,					block_out_channels=self.conditioning_embedding_out_channels			,					)

					_lowercase :    Union[str, Any]							=							self.only_cross_attention
					if isinstance(lowerCamelCase_			,					lowerCamelCase_						):
						_lowercase :    Optional[Any]							=							(only_cross_attention,) * len(self.down_block_types						)

					if isinstance(lowerCamelCase_			,					lowerCamelCase_						):
						_lowercase :    int							=							(num_attention_heads,) * len(self.down_block_types						)

					# down
					_lowercase :    Optional[int]							=							[]
					_lowercase :    str							=							[]

					_lowercase :    int							=							block_out_channels[0]

					_lowercase :    Any							=							nn.Conv(
					    lowerCamelCase_			,					kernel_size=(1, 1)			,					padding='VALID'			,					kernel_init=nn.initializers.zeros_init()			,					bias_init=nn.initializers.zeros_init()			,					dtype=self.dtype			,					)
					controlnet_down_blocks.append(lowerCamelCase_						)

					for i, down_block_type in enumerate(self.down_block_types						):
						_lowercase :    Optional[Any]							=							output_channel
						_lowercase :    Union[str, Any]							=							block_out_channels[i]
						_lowercase :    Tuple							=							i == len(lowerCamelCase_						) - 1

						if down_block_type == "CrossAttnDownBlock2D":
							_lowercase :    Dict							=							FlaxCrossAttnDownBlockaD(
							    in_channels=lowerCamelCase_			,					out_channels=lowerCamelCase_			,					dropout=self.dropout			,					num_layers=self.layers_per_block			,					num_attention_heads=num_attention_heads[i]			,					add_downsample=not is_final_block			,					use_linear_projection=self.use_linear_projection			,					only_cross_attention=only_cross_attention[i]			,					dtype=self.dtype			,					)
						else:
							_lowercase :    Any							=							FlaxDownBlockaD(
							    in_channels=lowerCamelCase_			,					out_channels=lowerCamelCase_			,					dropout=self.dropout			,					num_layers=self.layers_per_block			,					add_downsample=not is_final_block			,					dtype=self.dtype			,					)

						down_blocks.append(lowerCamelCase_						)

						for _ in range(self.layers_per_block						):
							_lowercase :    Any							=							nn.Conv(
							    lowerCamelCase_			,					kernel_size=(1, 1)			,					padding='VALID'			,					kernel_init=nn.initializers.zeros_init()			,					bias_init=nn.initializers.zeros_init()			,					dtype=self.dtype			,					)
							controlnet_down_blocks.append(lowerCamelCase_						)

						if not is_final_block:
							_lowercase :    Tuple							=							nn.Conv(
							    lowerCamelCase_			,					kernel_size=(1, 1)			,					padding='VALID'			,					kernel_init=nn.initializers.zeros_init()			,					bias_init=nn.initializers.zeros_init()			,					dtype=self.dtype			,					)
							controlnet_down_blocks.append(lowerCamelCase_						)

					_lowercase :    Optional[Any]							=							down_blocks
					_lowercase :    List[str]							=							controlnet_down_blocks

					# mid
					_lowercase :    int							=							block_out_channels[-1]
					_lowercase :    Union[str, Any]							=							FlaxUNetMidBlockaDCrossAttn(
					    in_channels=lowerCamelCase_			,					dropout=self.dropout			,					num_attention_heads=num_attention_heads[-1]			,					use_linear_projection=self.use_linear_projection			,					dtype=self.dtype			,					)

					_lowercase :    Tuple							=							nn.Conv(
					    lowerCamelCase_			,					kernel_size=(1, 1)			,					padding='VALID'			,					kernel_init=nn.initializers.zeros_init()			,					bias_init=nn.initializers.zeros_init()			,					dtype=self.dtype			,					)







				def __call__( self    :       Union[str, Any]			,					lowerCamelCase_    :       List[Any]			,					lowerCamelCase_    :       List[Any]			,					lowerCamelCase_    :       List[str]			,					lowerCamelCase_    :       Any			,					lowerCamelCase_    :       float = 1.0			,					lowerCamelCase_    :       bool = True			,					lowerCamelCase_    :       bool = False			,					):

					"""simple docstring"""






					_lowercase :    Union[str, Any]							=							self.controlnet_conditioning_channel_order
					if channel_order == "bgr":
						_lowercase :    Tuple							=							jnp.flip(lowerCamelCase_			,					axis=1						)

					# 1. time
					if not isinstance(lowerCamelCase_			,					jnp.ndarray						):
						_lowercase :    Union[str, Any]							=							jnp.array([timesteps]			,					dtype=jnp.intaa						)
					elif isinstance(lowerCamelCase_			,					jnp.ndarray						) and len(timesteps.shape						) == 0:
						_lowercase :    Optional[int]							=							timesteps.astype(dtype=jnp.floataa						)
						_lowercase :    str							=							jnp.expand_dims(lowerCamelCase_			,					0						)

					_lowercase :    List[str]							=							self.time_proj(lowerCamelCase_						)
					_lowercase :    Optional[int]							=							self.time_embedding(lowerCamelCase_						)

					# 2. pre-process
					_lowercase :    Tuple							=							jnp.transpose(lowerCamelCase_			,					(0, 2, 3, 1)						)
					_lowercase :    Dict							=							self.conv_in(lowerCamelCase_						)

					_lowercase :    Tuple							=							jnp.transpose(lowerCamelCase_			,					(0, 2, 3, 1)						)
					_lowercase :    List[str]							=							self.controlnet_cond_embedding(lowerCamelCase_						)
					sample += controlnet_cond

					# 3. down
					_lowercase :    List[str]							=							(sample,)
					for down_block in self.down_blocks:
						if isinstance(lowerCamelCase_			,					lowerCamelCase_						):
							_lowercase :    str							=							down_block(lowerCamelCase_			,					lowerCamelCase_			,					lowerCamelCase_			,					deterministic=not train						)
						else:
							_lowercase :    Optional[Any]							=							down_block(lowerCamelCase_			,					lowerCamelCase_			,					deterministic=not train						)
						down_block_res_samples += res_samples

					# 4. mid
					_lowercase :    Union[str, Any]							=							self.mid_block(lowerCamelCase_			,					lowerCamelCase_			,					lowerCamelCase_			,					deterministic=not train						)

					# 5. contronet blocks
					_lowercase :    Tuple							=							()
					for down_block_res_sample, controlnet_block in zip(lowerCamelCase_			,					self.controlnet_down_blocks						):
						_lowercase :    Tuple							=							controlnet_block(lowerCamelCase_						)
						controlnet_down_block_res_samples += (down_block_res_sample,)

					_lowercase :    Optional[Any]							=							controlnet_down_block_res_samples

					_lowercase :    Union[str, Any]							=							self.controlnet_mid_block(lowerCamelCase_						)

					# 6. scaling
					_lowercase :    int							=							[sample * conditioning_scale for sample in down_block_res_samples]
					mid_block_res_sample *= conditioning_scale

					if not return_dict:
						return (down_block_res_samples, mid_block_res_sample)

					return FlaxControlNetOutput(
					    down_block_res_samples=lowerCamelCase_			,					mid_block_res_sample=lowerCamelCase_						)




"""simple docstring"""







from __future__ import annotations

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



class  _lowerCamelCase			:







				def __init__( self    :       str			,					lowerCamelCase_    :       Collection[float] | None = None						):

					"""simple docstring"""






					if components is None:
						_lowercase :    Any							=							[]
					_lowercase :    int							=							list(lowerCamelCase_						)







				def __len__( self    :       int						):

					"""simple docstring"""






					return len(self.__components						)







				def __str__( self    :       List[Any]						):

					"""simple docstring"""






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







				def __add__( self    :       Dict			,					lowerCamelCase_    :       Vector						):

					"""simple docstring"""






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







				def __sub__( self    :       int			,					lowerCamelCase_    :       Vector						):

					"""simple docstring"""






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







				@overload
				def __mul__( self    :       Tuple			,					lowerCamelCase_    :       float						):

					"""simple docstring"""






					...







				@overload
				def __mul__( self    :       Tuple			,					lowerCamelCase_    :       Vector						):

					"""simple docstring"""






					...







				def __mul__( self    :       int			,					lowerCamelCase_    :       float | Vector						):

					"""simple docstring"""






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







				def 							__UpperCAmelCase					( self    :       Dict						):

					"""simple docstring"""






					return Vector(self.__components						)







				def 							__UpperCAmelCase					( self    :       List[str]			,					lowerCamelCase_    :       int						):

					"""simple docstring"""






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







				def 							__UpperCAmelCase					( self    :       str			,					lowerCamelCase_    :       int			,					lowerCamelCase_    :       float						):

					"""simple docstring"""






					assert -len(self.__components						) <= pos < len(self.__components						)
					_lowercase :    Tuple							=							value







				def 							__UpperCAmelCase					( self    :       List[Any]						):

					"""simple docstring"""






					if len(self.__components						) == 0:
						raise Exception('Vector is empty'						)
					_lowercase :    Optional[int]							=							[c**2 for c in self.__components]
					return math.sqrt(sum(lowerCamelCase_						)						)







				def 							__UpperCAmelCase					( self    :       int			,					lowerCamelCase_    :       Vector			,					lowerCamelCase_    :       bool = False						):

					"""simple docstring"""






					_lowercase :    int							=							self * other
					_lowercase :    Any							=							self.euclidean_length() * other.euclidean_length()
					if deg:
						return math.degrees(math.acos(num / den						)						)
					else:
						return math.acos(num / den						)



def      __lowerCAmelCase(		__UpperCAmelCase			):






	"""simple docstring"""





	assert isinstance(__UpperCAmelCase     ,__UpperCAmelCase			)
	return Vector([0] * dimension			)


def      __lowerCAmelCase(		__UpperCAmelCase     ,__UpperCAmelCase			):






	"""simple docstring"""





	assert isinstance(__UpperCAmelCase     ,__UpperCAmelCase			) and (isinstance(__UpperCAmelCase     ,__UpperCAmelCase			))
	_lowercase :    str							=							[0] * dimension
	_lowercase :    List[Any]							=							1
	return Vector(__UpperCAmelCase			)


def      __lowerCAmelCase(		__UpperCAmelCase     ,__UpperCAmelCase     ,__UpperCAmelCase			):






	"""simple docstring"""





	assert (
	    isinstance(__UpperCAmelCase     ,__UpperCAmelCase			)
	    and isinstance(__UpperCAmelCase     ,__UpperCAmelCase			)
	    and (isinstance(__UpperCAmelCase     ,(int, float)			))
	)
	return x * scalar + y


def      __lowerCAmelCase(		__UpperCAmelCase     ,__UpperCAmelCase     ,__UpperCAmelCase			):






	"""simple docstring"""





	random.seed(__UpperCAmelCase			)
	_lowercase :    Tuple							=							[random.randint(__UpperCAmelCase     ,__UpperCAmelCase			) for _ in range(__UpperCAmelCase			)]
	return Vector(__UpperCAmelCase			)



class  _lowerCamelCase			:







				def __init__( self    :       Dict			,					lowerCamelCase_    :       list[list[float]]			,					lowerCamelCase_    :       int			,					lowerCamelCase_    :       int						):

					"""simple docstring"""






					_lowercase :    Tuple							=							matrix
					_lowercase :    str							=							w
					_lowercase :    Tuple							=							h







				def __str__( self    :       int						):

					"""simple docstring"""






					_lowercase :    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    :       Dict			,					lowerCamelCase_    :       Matrix						):

					"""simple docstring"""






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







				def __sub__( self    :       str			,					lowerCamelCase_    :       Matrix						):

					"""simple docstring"""






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







				@overload
				def __mul__( self    :       Union[str, Any]			,					lowerCamelCase_    :       float						):

					"""simple docstring"""






					...







				@overload
				def __mul__( self    :       List[str]			,					lowerCamelCase_    :       Vector						):

					"""simple docstring"""






					...







				def __mul__( self    :       int			,					lowerCamelCase_    :       float | Vector						):

					"""simple docstring"""






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







				def 							__UpperCAmelCase					( self    :       Union[str, Any]						):

					"""simple docstring"""






					return self.__height







				def 							__UpperCAmelCase					( self    :       List[Any]						):

					"""simple docstring"""






					return self.__width







				def 							__UpperCAmelCase					( self    :       Optional[Any]			,					lowerCamelCase_    :       int			,					lowerCamelCase_    :       int						):

					"""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 							__UpperCAmelCase					( self    :       Optional[Any]			,					lowerCamelCase_    :       int			,					lowerCamelCase_    :       int			,					lowerCamelCase_    :       float						):

					"""simple docstring"""






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







				def 							__UpperCAmelCase					( self    :       int			,					lowerCamelCase_    :       int			,					lowerCamelCase_    :       int						):

					"""simple docstring"""






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







				def 							__UpperCAmelCase					( self    :       List[str]			,					lowerCamelCase_    :       int			,					lowerCamelCase_    :       int						):

					"""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(lowerCamelCase_			,					lowerCamelCase_						)
					else:
						raise Exception('Indices out of bounds'						)







				def 							__UpperCAmelCase					( self    :       Dict						):

					"""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:
						_lowercase :    Union[str, Any]							=							[
						    self.__matrix[0][y] * self.cofactor(0			,					lowerCamelCase_						) for y in range(self.__width						)
						]
						return sum(lowerCamelCase_						)



def      __lowerCAmelCase(		__UpperCAmelCase			):






	"""simple docstring"""





	_lowercase :    list[list[float]]							=							[[0] * n for _ in range(__UpperCAmelCase			)]
	return Matrix(__UpperCAmelCase     ,__UpperCAmelCase     ,__UpperCAmelCase			)







def      __lowerCAmelCase(		__UpperCAmelCase     ,__UpperCAmelCase     ,__UpperCAmelCase     ,__UpperCAmelCase			):






	"""simple docstring"""





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



