






from typing import Any, Callable, Dict, List, Optional, Union

import torch
from transformers import CLIPImageProcessor, CLIPTextModel, CLIPTokenizer

from diffusers import (
    AutoencoderKL,
    DDIMScheduler,
    DiffusionPipeline,
    LMSDiscreteScheduler,
    PNDMScheduler,
    StableDiffusionPipeline,
    UNetaDConditionModel,
)
from diffusers.pipelines.stable_diffusion import StableDiffusionPipelineOutput
from diffusers.pipelines.stable_diffusion.safety_checker import StableDiffusionSafetyChecker


__magic_name__   :  Union[str, Any]        =							'''CompVis/stable-diffusion-v1-1'''
__magic_name__   :  Dict        =							'''CompVis/stable-diffusion-v1-2'''
__magic_name__   :  List[Any]        =							'''CompVis/stable-diffusion-v1-3'''
__magic_name__   :  Dict        =							'''CompVis/stable-diffusion-v1-4'''





class 					A__     (     __snake_case ):

     '''simple docstring'''






     def __init__( self      :    int   ,						_SCREAMING_SNAKE_CASE      :    AutoencoderKL   ,						_SCREAMING_SNAKE_CASE      :    CLIPTextModel   ,						_SCREAMING_SNAKE_CASE      :    CLIPTokenizer   ,						_SCREAMING_SNAKE_CASE      :    UNetaDConditionModel   ,						_SCREAMING_SNAKE_CASE      :    Union[DDIMScheduler, PNDMScheduler, LMSDiscreteScheduler]   ,						_SCREAMING_SNAKE_CASE      :    StableDiffusionSafetyChecker   ,						_SCREAMING_SNAKE_CASE      :    CLIPImageProcessor   ,						_SCREAMING_SNAKE_CASE      :    bool = True   ,						):






           """simple docstring"""




           super()._init_()

           UpperCamelCase					       =  StableDiffusionPipeline.from_pretrained(_SCREAMING_SNAKE_CASE )
           UpperCamelCase					       =  StableDiffusionPipeline.from_pretrained(_SCREAMING_SNAKE_CASE )
           UpperCamelCase					       =  StableDiffusionPipeline.from_pretrained(_SCREAMING_SNAKE_CASE )
           UpperCamelCase					       =  StableDiffusionPipeline(
               vae=_SCREAMING_SNAKE_CASE   ,						text_encoder=_SCREAMING_SNAKE_CASE   ,						tokenizer=_SCREAMING_SNAKE_CASE   ,						unet=_SCREAMING_SNAKE_CASE   ,						scheduler=_SCREAMING_SNAKE_CASE   ,						safety_checker=_SCREAMING_SNAKE_CASE   ,						feature_extractor=_SCREAMING_SNAKE_CASE   ,						requires_safety_checker=_SCREAMING_SNAKE_CASE   ,						)

           self.register_modules(pipelinea=self.pipea   ,						pipelinea=self.pipea   ,						pipelinea=self.pipea   ,						pipelinea=self.pipea )







     @property
     def   _SCREAMING_SNAKE_CASE     ( self      :    str ):






           """simple docstring"""




           return {k: getattr(self   ,						_SCREAMING_SNAKE_CASE ) for k in self.config.keys() if not k.startswith('_' )}







     def   _SCREAMING_SNAKE_CASE     ( self      :    str   ,						_SCREAMING_SNAKE_CASE      :    Optional[Union[str, int]] = "auto" ):






           """simple docstring"""




           if slice_size == "auto":
                 # half the attention head size is usually a good trade-off between
                 # speed and memory
                 UpperCamelCase					       =  self.unet.config.attention_head_dim // 2
           self.unet.set_attention_slice(_SCREAMING_SNAKE_CASE )







     def   _SCREAMING_SNAKE_CASE     ( self      :    str ):






           """simple docstring"""




           self.enable_attention_slicing(_SCREAMING_SNAKE_CASE )







     @torch.no_grad()
     def   _SCREAMING_SNAKE_CASE     ( self      :    List[Any]   ,						_SCREAMING_SNAKE_CASE      :    Union[str, List[str]]   ,						_SCREAMING_SNAKE_CASE      :    int = 512   ,						_SCREAMING_SNAKE_CASE      :    int = 512   ,						_SCREAMING_SNAKE_CASE      :    int = 50   ,						_SCREAMING_SNAKE_CASE      :    float = 7.5   ,						_SCREAMING_SNAKE_CASE      :    Optional[Union[str, List[str]]] = None   ,						_SCREAMING_SNAKE_CASE      :    Optional[int] = 1   ,						_SCREAMING_SNAKE_CASE      :    float = 0.0   ,						_SCREAMING_SNAKE_CASE      :    Optional[torch.Generator] = None   ,						_SCREAMING_SNAKE_CASE      :    Optional[torch.FloatTensor] = None   ,						_SCREAMING_SNAKE_CASE      :    Optional[str] = "pil"   ,						_SCREAMING_SNAKE_CASE      :    bool = True   ,						_SCREAMING_SNAKE_CASE      :    Optional[Callable[[int, int, torch.FloatTensor], None]] = None   ,						_SCREAMING_SNAKE_CASE      :    int = 1   ,						**_SCREAMING_SNAKE_CASE      :    Union[str, Any]   ,						):






           """simple docstring"""




           return self.pipea(
               prompt=_SCREAMING_SNAKE_CASE   ,						height=_SCREAMING_SNAKE_CASE   ,						width=_SCREAMING_SNAKE_CASE   ,						num_inference_steps=_SCREAMING_SNAKE_CASE   ,						guidance_scale=_SCREAMING_SNAKE_CASE   ,						negative_prompt=_SCREAMING_SNAKE_CASE   ,						num_images_per_prompt=_SCREAMING_SNAKE_CASE   ,						eta=_SCREAMING_SNAKE_CASE   ,						generator=_SCREAMING_SNAKE_CASE   ,						latents=_SCREAMING_SNAKE_CASE   ,						output_type=_SCREAMING_SNAKE_CASE   ,						return_dict=_SCREAMING_SNAKE_CASE   ,						callback=_SCREAMING_SNAKE_CASE   ,						callback_steps=_SCREAMING_SNAKE_CASE   ,						**_SCREAMING_SNAKE_CASE   ,						)







     @torch.no_grad()
     def   _SCREAMING_SNAKE_CASE     ( self      :    str   ,						_SCREAMING_SNAKE_CASE      :    Union[str, List[str]]   ,						_SCREAMING_SNAKE_CASE      :    int = 512   ,						_SCREAMING_SNAKE_CASE      :    int = 512   ,						_SCREAMING_SNAKE_CASE      :    int = 50   ,						_SCREAMING_SNAKE_CASE      :    float = 7.5   ,						_SCREAMING_SNAKE_CASE      :    Optional[Union[str, List[str]]] = None   ,						_SCREAMING_SNAKE_CASE      :    Optional[int] = 1   ,						_SCREAMING_SNAKE_CASE      :    float = 0.0   ,						_SCREAMING_SNAKE_CASE      :    Optional[torch.Generator] = None   ,						_SCREAMING_SNAKE_CASE      :    Optional[torch.FloatTensor] = None   ,						_SCREAMING_SNAKE_CASE      :    Optional[str] = "pil"   ,						_SCREAMING_SNAKE_CASE      :    bool = True   ,						_SCREAMING_SNAKE_CASE      :    Optional[Callable[[int, int, torch.FloatTensor], None]] = None   ,						_SCREAMING_SNAKE_CASE      :    int = 1   ,						**_SCREAMING_SNAKE_CASE      :    Any   ,						):






           """simple docstring"""




           return self.pipea(
               prompt=_SCREAMING_SNAKE_CASE   ,						height=_SCREAMING_SNAKE_CASE   ,						width=_SCREAMING_SNAKE_CASE   ,						num_inference_steps=_SCREAMING_SNAKE_CASE   ,						guidance_scale=_SCREAMING_SNAKE_CASE   ,						negative_prompt=_SCREAMING_SNAKE_CASE   ,						num_images_per_prompt=_SCREAMING_SNAKE_CASE   ,						eta=_SCREAMING_SNAKE_CASE   ,						generator=_SCREAMING_SNAKE_CASE   ,						latents=_SCREAMING_SNAKE_CASE   ,						output_type=_SCREAMING_SNAKE_CASE   ,						return_dict=_SCREAMING_SNAKE_CASE   ,						callback=_SCREAMING_SNAKE_CASE   ,						callback_steps=_SCREAMING_SNAKE_CASE   ,						**_SCREAMING_SNAKE_CASE   ,						)







     @torch.no_grad()
     def   _SCREAMING_SNAKE_CASE     ( self      :    Optional[int]   ,						_SCREAMING_SNAKE_CASE      :    Union[str, List[str]]   ,						_SCREAMING_SNAKE_CASE      :    int = 512   ,						_SCREAMING_SNAKE_CASE      :    int = 512   ,						_SCREAMING_SNAKE_CASE      :    int = 50   ,						_SCREAMING_SNAKE_CASE      :    float = 7.5   ,						_SCREAMING_SNAKE_CASE      :    Optional[Union[str, List[str]]] = None   ,						_SCREAMING_SNAKE_CASE      :    Optional[int] = 1   ,						_SCREAMING_SNAKE_CASE      :    float = 0.0   ,						_SCREAMING_SNAKE_CASE      :    Optional[torch.Generator] = None   ,						_SCREAMING_SNAKE_CASE      :    Optional[torch.FloatTensor] = None   ,						_SCREAMING_SNAKE_CASE      :    Optional[str] = "pil"   ,						_SCREAMING_SNAKE_CASE      :    bool = True   ,						_SCREAMING_SNAKE_CASE      :    Optional[Callable[[int, int, torch.FloatTensor], None]] = None   ,						_SCREAMING_SNAKE_CASE      :    int = 1   ,						**_SCREAMING_SNAKE_CASE      :    Optional[int]   ,						):






           """simple docstring"""




           return self.pipea(
               prompt=_SCREAMING_SNAKE_CASE   ,						height=_SCREAMING_SNAKE_CASE   ,						width=_SCREAMING_SNAKE_CASE   ,						num_inference_steps=_SCREAMING_SNAKE_CASE   ,						guidance_scale=_SCREAMING_SNAKE_CASE   ,						negative_prompt=_SCREAMING_SNAKE_CASE   ,						num_images_per_prompt=_SCREAMING_SNAKE_CASE   ,						eta=_SCREAMING_SNAKE_CASE   ,						generator=_SCREAMING_SNAKE_CASE   ,						latents=_SCREAMING_SNAKE_CASE   ,						output_type=_SCREAMING_SNAKE_CASE   ,						return_dict=_SCREAMING_SNAKE_CASE   ,						callback=_SCREAMING_SNAKE_CASE   ,						callback_steps=_SCREAMING_SNAKE_CASE   ,						**_SCREAMING_SNAKE_CASE   ,						)







     @torch.no_grad()
     def   _SCREAMING_SNAKE_CASE     ( self      :    str   ,						_SCREAMING_SNAKE_CASE      :    Union[str, List[str]]   ,						_SCREAMING_SNAKE_CASE      :    int = 512   ,						_SCREAMING_SNAKE_CASE      :    int = 512   ,						_SCREAMING_SNAKE_CASE      :    int = 50   ,						_SCREAMING_SNAKE_CASE      :    float = 7.5   ,						_SCREAMING_SNAKE_CASE      :    Optional[Union[str, List[str]]] = None   ,						_SCREAMING_SNAKE_CASE      :    Optional[int] = 1   ,						_SCREAMING_SNAKE_CASE      :    float = 0.0   ,						_SCREAMING_SNAKE_CASE      :    Optional[torch.Generator] = None   ,						_SCREAMING_SNAKE_CASE      :    Optional[torch.FloatTensor] = None   ,						_SCREAMING_SNAKE_CASE      :    Optional[str] = "pil"   ,						_SCREAMING_SNAKE_CASE      :    bool = True   ,						_SCREAMING_SNAKE_CASE      :    Optional[Callable[[int, int, torch.FloatTensor], None]] = None   ,						_SCREAMING_SNAKE_CASE      :    int = 1   ,						**_SCREAMING_SNAKE_CASE      :    Optional[int]   ,						):






           """simple docstring"""




           return self.pipea(
               prompt=_SCREAMING_SNAKE_CASE   ,						height=_SCREAMING_SNAKE_CASE   ,						width=_SCREAMING_SNAKE_CASE   ,						num_inference_steps=_SCREAMING_SNAKE_CASE   ,						guidance_scale=_SCREAMING_SNAKE_CASE   ,						negative_prompt=_SCREAMING_SNAKE_CASE   ,						num_images_per_prompt=_SCREAMING_SNAKE_CASE   ,						eta=_SCREAMING_SNAKE_CASE   ,						generator=_SCREAMING_SNAKE_CASE   ,						latents=_SCREAMING_SNAKE_CASE   ,						output_type=_SCREAMING_SNAKE_CASE   ,						return_dict=_SCREAMING_SNAKE_CASE   ,						callback=_SCREAMING_SNAKE_CASE   ,						callback_steps=_SCREAMING_SNAKE_CASE   ,						**_SCREAMING_SNAKE_CASE   ,						)







     @torch.no_grad()
     def   _SCREAMING_SNAKE_CASE     ( self      :    Dict   ,						_SCREAMING_SNAKE_CASE      :    Union[str, List[str]]   ,						_SCREAMING_SNAKE_CASE      :    int = 512   ,						_SCREAMING_SNAKE_CASE      :    int = 512   ,						_SCREAMING_SNAKE_CASE      :    int = 50   ,						_SCREAMING_SNAKE_CASE      :    float = 7.5   ,						_SCREAMING_SNAKE_CASE      :    Optional[Union[str, List[str]]] = None   ,						_SCREAMING_SNAKE_CASE      :    Optional[int] = 1   ,						_SCREAMING_SNAKE_CASE      :    float = 0.0   ,						_SCREAMING_SNAKE_CASE      :    Optional[torch.Generator] = None   ,						_SCREAMING_SNAKE_CASE      :    Optional[torch.FloatTensor] = None   ,						_SCREAMING_SNAKE_CASE      :    Optional[str] = "pil"   ,						_SCREAMING_SNAKE_CASE      :    bool = True   ,						_SCREAMING_SNAKE_CASE      :    Optional[Callable[[int, int, torch.FloatTensor], None]] = None   ,						_SCREAMING_SNAKE_CASE      :    int = 1   ,						**_SCREAMING_SNAKE_CASE      :    Any   ,						):






           """simple docstring"""




           UpperCamelCase					       =  'cuda' if torch.cuda.is_available() else 'cpu'
           self.to(_SCREAMING_SNAKE_CASE )

           # Checks if the height and width are divisible by 8 or not
           if height % 8 != 0 or width % 8 != 0:
                 raise ValueError(f'`height` and `width` must be divisible by 8 but are {height} and {width}.' )

           # Get first result from Stable Diffusion Checkpoint v1.1
           UpperCamelCase					       =  self.textaimg_sda_a(
               prompt=_SCREAMING_SNAKE_CASE   ,						height=_SCREAMING_SNAKE_CASE   ,						width=_SCREAMING_SNAKE_CASE   ,						num_inference_steps=_SCREAMING_SNAKE_CASE   ,						guidance_scale=_SCREAMING_SNAKE_CASE   ,						negative_prompt=_SCREAMING_SNAKE_CASE   ,						num_images_per_prompt=_SCREAMING_SNAKE_CASE   ,						eta=_SCREAMING_SNAKE_CASE   ,						generator=_SCREAMING_SNAKE_CASE   ,						latents=_SCREAMING_SNAKE_CASE   ,						output_type=_SCREAMING_SNAKE_CASE   ,						return_dict=_SCREAMING_SNAKE_CASE   ,						callback=_SCREAMING_SNAKE_CASE   ,						callback_steps=_SCREAMING_SNAKE_CASE   ,						**_SCREAMING_SNAKE_CASE   ,						)

           # Get first result from Stable Diffusion Checkpoint v1.2
           UpperCamelCase					       =  self.textaimg_sda_a(
               prompt=_SCREAMING_SNAKE_CASE   ,						height=_SCREAMING_SNAKE_CASE   ,						width=_SCREAMING_SNAKE_CASE   ,						num_inference_steps=_SCREAMING_SNAKE_CASE   ,						guidance_scale=_SCREAMING_SNAKE_CASE   ,						negative_prompt=_SCREAMING_SNAKE_CASE   ,						num_images_per_prompt=_SCREAMING_SNAKE_CASE   ,						eta=_SCREAMING_SNAKE_CASE   ,						generator=_SCREAMING_SNAKE_CASE   ,						latents=_SCREAMING_SNAKE_CASE   ,						output_type=_SCREAMING_SNAKE_CASE   ,						return_dict=_SCREAMING_SNAKE_CASE   ,						callback=_SCREAMING_SNAKE_CASE   ,						callback_steps=_SCREAMING_SNAKE_CASE   ,						**_SCREAMING_SNAKE_CASE   ,						)

           # Get first result from Stable Diffusion Checkpoint v1.3
           UpperCamelCase					       =  self.textaimg_sda_a(
               prompt=_SCREAMING_SNAKE_CASE   ,						height=_SCREAMING_SNAKE_CASE   ,						width=_SCREAMING_SNAKE_CASE   ,						num_inference_steps=_SCREAMING_SNAKE_CASE   ,						guidance_scale=_SCREAMING_SNAKE_CASE   ,						negative_prompt=_SCREAMING_SNAKE_CASE   ,						num_images_per_prompt=_SCREAMING_SNAKE_CASE   ,						eta=_SCREAMING_SNAKE_CASE   ,						generator=_SCREAMING_SNAKE_CASE   ,						latents=_SCREAMING_SNAKE_CASE   ,						output_type=_SCREAMING_SNAKE_CASE   ,						return_dict=_SCREAMING_SNAKE_CASE   ,						callback=_SCREAMING_SNAKE_CASE   ,						callback_steps=_SCREAMING_SNAKE_CASE   ,						**_SCREAMING_SNAKE_CASE   ,						)

           # Get first result from Stable Diffusion Checkpoint v1.4
           UpperCamelCase					       =  self.textaimg_sda_a(
               prompt=_SCREAMING_SNAKE_CASE   ,						height=_SCREAMING_SNAKE_CASE   ,						width=_SCREAMING_SNAKE_CASE   ,						num_inference_steps=_SCREAMING_SNAKE_CASE   ,						guidance_scale=_SCREAMING_SNAKE_CASE   ,						negative_prompt=_SCREAMING_SNAKE_CASE   ,						num_images_per_prompt=_SCREAMING_SNAKE_CASE   ,						eta=_SCREAMING_SNAKE_CASE   ,						generator=_SCREAMING_SNAKE_CASE   ,						latents=_SCREAMING_SNAKE_CASE   ,						output_type=_SCREAMING_SNAKE_CASE   ,						return_dict=_SCREAMING_SNAKE_CASE   ,						callback=_SCREAMING_SNAKE_CASE   ,						callback_steps=_SCREAMING_SNAKE_CASE   ,						**_SCREAMING_SNAKE_CASE   ,						)

           # Get all result images into a single list and pass it via StableDiffusionPipelineOutput for final result
           return StableDiffusionPipelineOutput([resa[0], resa[0], resa[0], resa[0]] )











from __future__ import annotations

import math
def 		lowercase__  (				_UpperCamelCase       ,							_UpperCamelCase) ->			list:
      """simple docstring"""

      if len(_UpperCamelCase) != 2 or len(a[0]) != 2 or len(_UpperCamelCase) != 2 or len(b[0]) != 2:
            raise Exception('Matrices are not 2x2')
      UpperCamelCase					       =  [
          [a[0][0] * b[0][0] + a[0][1] * b[1][0], a[0][0] * b[0][1] + a[0][1] * b[1][1]],
          [a[1][0] * b[0][0] + a[1][1] * b[1][0], a[1][0] * b[0][1] + a[1][1] * b[1][1]],
      ]
      return new_matrix
def 		lowercase__  (				_UpperCamelCase       ,							_UpperCamelCase) ->			Union[str, Any]:
      """simple docstring"""

      return [
          [matrix_a[row][col] + matrix_b[row][col] for col in range(len(matrix_a[row]))]
          for row in range(len(_UpperCamelCase))
      ]
def 		lowercase__  (				_UpperCamelCase       ,							_UpperCamelCase) ->			Optional[int]:
      """simple docstring"""

      return [
          [matrix_a[row][col] - matrix_b[row][col] for col in range(len(matrix_a[row]))]
          for row in range(len(_UpperCamelCase))
      ]
def 		lowercase__  (				_UpperCamelCase) ->			tuple[list, list, list, list]:
      """simple docstring"""

      if len(_UpperCamelCase) % 2 != 0 or len(a[0]) % 2 != 0:
            raise Exception('Odd matrices are not supported!')

      UpperCamelCase					       =  len(_UpperCamelCase)
      UpperCamelCase					       =  matrix_length // 2

      UpperCamelCase					       =  [[a[i][j] for j in range(_UpperCamelCase       ,							_UpperCamelCase)] for i in range(_UpperCamelCase)]
      UpperCamelCase					       =  [
          [a[i][j] for j in range(_UpperCamelCase       ,							_UpperCamelCase)] for i in range(_UpperCamelCase       ,							_UpperCamelCase)
      ]

      UpperCamelCase					       =  [[a[i][j] for j in range(_UpperCamelCase)] for i in range(_UpperCamelCase)]
      UpperCamelCase					       =  [[a[i][j] for j in range(_UpperCamelCase)] for i in range(_UpperCamelCase       ,							_UpperCamelCase)]

      return top_left, top_right, bot_left, bot_right
def 		lowercase__  (				_UpperCamelCase) ->			tuple[int, int]:
      """simple docstring"""

      return len(_UpperCamelCase), len(matrix[0])
def 		lowercase__  (				_UpperCamelCase) ->			None:
      """simple docstring"""

      print('\n'.join(str(_UpperCamelCase) for line in matrix))
def 		lowercase__  (				_UpperCamelCase       ,							_UpperCamelCase) ->			list:
      """simple docstring"""

      if matrix_dimensions(_UpperCamelCase) == (2, 2):
            return default_matrix_multiplication(_UpperCamelCase       ,							_UpperCamelCase)

      UpperCamelCase       ,  UpperCamelCase       ,  UpperCamelCase       ,  UpperCamelCase					       =  split_matrix(_UpperCamelCase)
      UpperCamelCase       ,  UpperCamelCase       ,  UpperCamelCase       ,  UpperCamelCase					       =  split_matrix(_UpperCamelCase)

      UpperCamelCase					       =  actual_strassen(_UpperCamelCase       ,							matrix_subtraction(_UpperCamelCase       ,							_UpperCamelCase))
      UpperCamelCase					       =  actual_strassen(matrix_addition(_UpperCamelCase       ,							_UpperCamelCase)       ,							_UpperCamelCase)
      UpperCamelCase					       =  actual_strassen(matrix_addition(_UpperCamelCase       ,							_UpperCamelCase)       ,							_UpperCamelCase)
      UpperCamelCase					       =  actual_strassen(_UpperCamelCase       ,							matrix_subtraction(_UpperCamelCase       ,							_UpperCamelCase))
      UpperCamelCase					       =  actual_strassen(matrix_addition(_UpperCamelCase       ,							_UpperCamelCase)       ,							matrix_addition(_UpperCamelCase       ,							_UpperCamelCase))
      UpperCamelCase					       =  actual_strassen(matrix_subtraction(_UpperCamelCase       ,							_UpperCamelCase)       ,							matrix_addition(_UpperCamelCase       ,							_UpperCamelCase))
      UpperCamelCase					       =  actual_strassen(matrix_subtraction(_UpperCamelCase       ,							_UpperCamelCase)       ,							matrix_addition(_UpperCamelCase       ,							_UpperCamelCase))

      UpperCamelCase					       =  matrix_addition(matrix_subtraction(matrix_addition(_UpperCamelCase       ,							_UpperCamelCase)       ,							_UpperCamelCase)       ,							_UpperCamelCase)
      UpperCamelCase					       =  matrix_addition(_UpperCamelCase       ,							_UpperCamelCase)
      UpperCamelCase					       =  matrix_addition(_UpperCamelCase       ,							_UpperCamelCase)
      UpperCamelCase					       =  matrix_subtraction(matrix_subtraction(matrix_addition(_UpperCamelCase       ,							_UpperCamelCase)       ,							_UpperCamelCase)       ,							_UpperCamelCase)

      # construct the new matrix from our 4 quadrants
      UpperCamelCase					       =  []
      for i in range(len(_UpperCamelCase)):
            new_matrix.append(top_left[i] + top_right[i])
      for i in range(len(_UpperCamelCase)):
            new_matrix.append(bot_left[i] + bot_right[i])
      return new_matrix
def 		lowercase__  (				_UpperCamelCase       ,							_UpperCamelCase) ->			list:
      """simple docstring"""

      if matrix_dimensions(_UpperCamelCase)[1] != matrix_dimensions(_UpperCamelCase)[0]:
            UpperCamelCase					       =  (
                'Unable to multiply these matrices, please check the dimensions.\n'
                F'Matrix A: {matrixa}\n'
                F'Matrix B: {matrixa}'
            )
            raise Exception(_UpperCamelCase)
      UpperCamelCase					       =  matrix_dimensions(_UpperCamelCase)
      UpperCamelCase					       =  matrix_dimensions(_UpperCamelCase)

      if dimensiona[0] == dimensiona[1] and dimensiona[0] == dimensiona[1]:
            return [matrixa, matrixa]

      UpperCamelCase					       =  max(*_UpperCamelCase       ,							*_UpperCamelCase)
      UpperCamelCase					       =  int(math.pow(2       ,							math.ceil(math.loga(_UpperCamelCase))))
      UpperCamelCase					       =  matrixa
      UpperCamelCase					       =  matrixa

      # Adding zeros to the matrices so that the arrays dimensions are the same and also
      # power of 2
      for i in range(0       ,							_UpperCamelCase):
            if i < dimensiona[0]:
                  for _ in range(dimensiona[1]       ,							_UpperCamelCase):
                        new_matrixa[i].append(0)
            else:
                  new_matrixa.append([0] * maxim)
            if i < dimensiona[0]:
                  for _ in range(dimensiona[1]       ,							_UpperCamelCase):
                        new_matrixa[i].append(0)
            else:
                  new_matrixa.append([0] * maxim)

      UpperCamelCase					       =  actual_strassen(_UpperCamelCase       ,							_UpperCamelCase)

      # Removing the additional zeros
      for i in range(0       ,							_UpperCamelCase):
            if i < dimensiona[0]:
                  for _ in range(dimensiona[1]       ,							_UpperCamelCase):
                        final_matrix[i].pop()
            else:
                  final_matrix.pop()
      return final_matrix


if __name__ == "__main__":
       __magic_name__   :  Optional[Any]        =							[
           [2, 3, 4, 5],
           [6, 4, 3, 1],
           [2, 3, 6, 7],
           [3, 1, 2, 4],
           [2, 3, 4, 5],
           [6, 4, 3, 1],
           [2, 3, 6, 7],
           [3, 1, 2, 4],
           [2, 3, 4, 5],
           [6, 2, 3, 1],
       ]
       __magic_name__   :  List[str]        =							[[0, 2, 1, 1], [16, 2, 3, 3], [2, 2, 7, 7], [13, 11, 22, 4]]
       print(strassen(matrixa, matrixa))



