code: 
  
  
  
  from __future__ import annotations
  
  from typing import Any
  
  
  
  
  
  
  def 			__lowercase     (				*a__     )       ->				list[list[int]]:
  							if all(_check_not_integer(a__     ) for m in matrix_s     ):
  														for i in matrix_s[1:]:
  																					_verify_matrix_sizes(matrix_s[0]							,     a__     )
  														return [[sum(a__     ) for t in zip(*a__     )] for m in zip(*a__     )]
  							raise TypeError('Expected a matrix, got int/list instead'     )
  
  
  
  
  
  
  def 			__lowercase     (				a__							,     a__     )       ->				list[list[int]]:
  							if (
  							    _check_not_integer(a__     )
  							    and _check_not_integer(a__     )
  							    and _verify_matrix_sizes(a__							,     a__     )
  							):
  														return [[i - j for i, j in zip(*a__     )] for m in zip(a__							,     a__     )]
  							raise TypeError('Expected a matrix, got int/list instead'     )
  
  
  
  
  
  
  def 			__lowercase     (				a__							,     a__     )       ->				list[list[float]]:
  							return [[x * n for x in row] for row in matrix]
  
  
  
  
  
  
  def 			__lowercase     (				a__							,     a__     )       ->				list[list[int]]:
  							if _check_not_integer(a__     ) and _check_not_integer(a__     ):
  														__SCREAMING_SNAKE_CASE							, __SCREAMING_SNAKE_CASE								=      _verify_matrix_sizes(a__							,     a__     )
  
  							if cols[0] != rows[1]:
  														__SCREAMING_SNAKE_CASE								=      (
  														    'Cannot multiply matrix of dimensions '
  														    f"""({rows[0]},{cols[0]}) and ({rows[1]},{cols[1]})"""
  														)
  														raise ValueError(a__     )
  							return [
  							    [sum(m * n for m, n in zip(a__							,     a__     )     ) for j in zip(*a__     )] for i in matrix_a
  							]
  
  
  
  
  
  
  def 			__lowercase     (				a__     )       ->				list[list[int]]:
  							__SCREAMING_SNAKE_CASE								=      int(a__     )
  							return [[int(row == column     ) for column in range(a__     )] for row in range(a__     )]
  
  
  
  
  
  
  def 			__lowercase     (				a__							,     a__ = True     )       ->				list[list[int]] | map[list[int]]:
  							if _check_not_integer(a__     ):
  														if return_map:
  																					return map(a__							,     zip(*a__     )     )
  														else:
  																					return list(map(a__							,     zip(*a__     )     )     )
  							raise TypeError('Expected a matrix, got int/list instead'     )
  
  
  
  
  
  
  def 			__lowercase     (				a__							,     a__							,     a__     )       ->				list[list[int]]:
  							__SCREAMING_SNAKE_CASE								=      matrix[:row] + matrix[row + 1 :]
  							return [row[:column] + row[column + 1 :] for row in minor]
  
  
  
  
  
  
  def 			__lowercase     (				a__     )       ->				Any:
  							if len(a__     ) == 1:
  														return matrix[0][0]
  
  							return sum(
  							    x * determinant(minor(a__							,     0							,     a__     )     ) * (-1) ** i
  							    for i, x in enumerate(matrix[0]     )     )
  
  
  
  
  
  
  def 			__lowercase     (				a__     )       ->				list[list[float]] | None:
  							__SCREAMING_SNAKE_CASE								=      determinant(a__     )
  							if det == 0:
  														return None
  
  							__SCREAMING_SNAKE_CASE								=      [
  							    [determinant(minor(a__							,     a__							,     a__     )     ) for j in range(len(a__     )     )]
  							    for i in range(len(a__     )     )
  							]
  
  							__SCREAMING_SNAKE_CASE								=      [
  							    [x * (-1) ** (row + col) for col, x in enumerate(matrix_minor[row]     )]
  							    for row in range(len(a__     )     )
  							]
  							__SCREAMING_SNAKE_CASE								=      list(transpose(a__     )     )
  							return scalar_multiply(a__							,     1 / det     )
  
  
  
  
  
  
  def 			__lowercase     (				a__     )       ->				bool:
  							return not isinstance(a__							,     a__     ) and not isinstance(matrix[0]							,     a__     )
  
  
  
  
  
  
  def 			__lowercase     (				a__     )       ->				tuple[int, int]:
  							return len(a__     ), len(matrix[0]     )
  
  
  
  
  
  
  def 			__lowercase     (				a__							,     a__     )       ->				tuple[tuple[int, int], tuple[int, int]]:
  							__SCREAMING_SNAKE_CASE								=      _shape(a__     ) + _shape(a__     )
  							if shape[0] != shape[3] or shape[1] != shape[2]:
  														__SCREAMING_SNAKE_CASE								=      (
  														    'operands could not be broadcast together with shape '
  														    f"""({shape[0], shape[1]}), ({shape[2], shape[3]})"""
  														)
  														raise ValueError(a__     )
  							return (shape[0], shape[2]), (shape[1], shape[3])
  
  
  
  
  
  
  def 			__lowercase     (				)       ->				None:
  							__SCREAMING_SNAKE_CASE								=      [[12, 10], [3, 9]]
  							__SCREAMING_SNAKE_CASE								=      [[3, 4], [7, 4]]
  							__SCREAMING_SNAKE_CASE								=      [[11, 12, 13, 14], [21, 22, 23, 24], [31, 32, 33, 34], [41, 42, 43, 44]]
  							__SCREAMING_SNAKE_CASE								=      [[3, 0, 2], [2, 0, -2], [0, 1, 1]]
  							print(f"""Add Operation, {add(a__							,     a__     ) = } \n"""     )
  							print(
  							    f"""Multiply Operation, {multiply(a__							,     a__     ) = } \n"""							,     )
  							print(f"""Identity: {identity(5     )}\n"""     )
  							print(f"""Minor of {matrix_c} = {minor(a__							,     1							,     2     )} \n"""     )
  							print(f"""Determinant of {matrix_b} = {determinant(a__     )} \n"""     )
  							print(f"""Inverse of {matrix_d} = {inverse(a__     )}\n"""     )
  
  
  if __name__ == "__main__":
  			import doctest
  
  			doctest.testmod()
  			main()
  
  
  
  
  
  
  
style_context: 
  
  
  
  import unittest
  
  from cer import CER
  
  
  lowerCAmelCase__	:  Dict 		=CER()
  
  class      UpperCAmelCase_						(     unittest.TestCase ):
  
  						'''simple docstring'''
  
  
  
  
  						def  _A			(					self	):
  
  
  
  
  
  
  
  													'''simple docstring'''
  
  													__SCREAMING_SNAKE_CASE								=      ['White House']
  													__SCREAMING_SNAKE_CASE								=      ['white house']
  													# S = 2, D = 0, I = 0, N = 11, CER = 2 / 11
  													__SCREAMING_SNAKE_CASE								=      cer.compute(predictions=_A   ,							references=_A	)
  													self.assertTrue(abs(char_error_rate - 0.1_8_1_8_1_8_1_8_1_8	) < 1e-6	)
  
  
  
  
  
  
  						def  _A			(					self	):
  
  
  
  
  
  
  
  													'''simple docstring'''
  
  													__SCREAMING_SNAKE_CASE								=      ['were wolf']
  													__SCREAMING_SNAKE_CASE								=      ['werewolf']
  													# S = 0, D = 0, I = 1, N = 9, CER = 1 / 9
  													__SCREAMING_SNAKE_CASE								=      cer.compute(predictions=_A   ,							references=_A	)
  													self.assertTrue(abs(char_error_rate - 0.1_1_1_1_1_1_1	) < 1e-6	)
  
  													__SCREAMING_SNAKE_CASE								=      ['werewolf']
  													__SCREAMING_SNAKE_CASE								=      ['weae     wolf']
  													# S = 1, D = 1, I = 0, N = 8, CER = 0.25
  													__SCREAMING_SNAKE_CASE								=      cer.compute(predictions=_A   ,							references=_A	)
  													self.assertTrue(abs(char_error_rate - 0.2_5	) < 1e-6	)
  
  													# consecutive whitespaces case 1
  													__SCREAMING_SNAKE_CASE								=      ['were wolf']
  													__SCREAMING_SNAKE_CASE								=      ['were               wolf']
  													# S = 0, D = 0, I = 0, N = 9, CER = 0
  													__SCREAMING_SNAKE_CASE								=      cer.compute(predictions=_A   ,							references=_A	)
  													self.assertTrue(abs(char_error_rate - 0.0	) < 1e-6	)
  
  													# consecutive whitespaces case 2
  													__SCREAMING_SNAKE_CASE								=      ['were   wolf']
  													__SCREAMING_SNAKE_CASE								=      ['were               wolf']
  													# S = 0, D = 0, I = 0, N = 9, CER = 0
  													__SCREAMING_SNAKE_CASE								=      cer.compute(predictions=_A   ,							references=_A	)
  													self.assertTrue(abs(char_error_rate - 0.0	) < 1e-6	)
  
  
  
  
  
  
  						def  _A			(					self	):
  
  
  
  
  
  
  
  													'''simple docstring'''
  
  													__SCREAMING_SNAKE_CASE								=      ['werewolf']
  													__SCREAMING_SNAKE_CASE								=      ['weaewolf']
  													# S = 1, D = 0, I = 0, N = 8, CER = 0.125
  													__SCREAMING_SNAKE_CASE								=      cer.compute(predictions=_A   ,							references=_A	)
  													self.assertTrue(abs(char_error_rate - 0.1_2_5	) < 1e-6	)
  
  
  
  
  
  
  						def  _A			(					self	):
  
  
  
  
  
  
  
  													'''simple docstring'''
  
  													__SCREAMING_SNAKE_CASE								=      ['werewolf']
  													__SCREAMING_SNAKE_CASE								=      ['wereawolf']
  													# S = 0, D = 1, I = 0, N = 8, CER = 0.125
  													__SCREAMING_SNAKE_CASE								=      cer.compute(predictions=_A   ,							references=_A	)
  													self.assertTrue(abs(char_error_rate - 0.1_2_5	) < 1e-6	)
  
  
  
  
  
  
  						def  _A			(					self	):
  
  
  
  
  
  
  
  													'''simple docstring'''
  
  													__SCREAMING_SNAKE_CASE								=      ['werewolf']
  													__SCREAMING_SNAKE_CASE								=      ['wereolf']
  													# S = 0, D = 0, I = 1, N = 8, CER = 0.125
  													__SCREAMING_SNAKE_CASE								=      cer.compute(predictions=_A   ,							references=_A	)
  													self.assertTrue(abs(char_error_rate - 0.1_2_5	) < 1e-6	)
  
  
  
  
  
  
  						def  _A			(					self	):
  
  
  
  
  
  
  
  													'''simple docstring'''
  
  													__SCREAMING_SNAKE_CASE								=      ['werewolf']
  													__SCREAMING_SNAKE_CASE								=      cer.compute(predictions=_A   ,							references=_A	)
  													self.assertEqual(_A   ,							0.0	)
  
  
  
  
  
  
  						def  _A			(					self	):
  
  
  
  
  
  
  
  													'''simple docstring'''
  
  													__SCREAMING_SNAKE_CASE								=      ['werewolf', 'I am your father']
  													__SCREAMING_SNAKE_CASE								=      cer.compute(predictions=_A   ,							references=_A	)
  													self.assertEqual(_A   ,							0.0	)
  
  													__SCREAMING_SNAKE_CASE								=      ['werewolf', 'I am your father', 'doge']
  													__SCREAMING_SNAKE_CASE								=      ['werxwolf', 'I       am your father', 'doge']
  													# S = 1, D = 0, I = 0, N = 28, CER = 1 / 28
  													__SCREAMING_SNAKE_CASE								=      cer.compute(predictions=_A   ,							references=_A	)
  													self.assertTrue(abs(char_error_rate - 0.0_3_5_7_1_4_2_8	) < 1e-6	)
  
  
  
  
  
  
  						def  _A			(					self	):
  
  
  
  
  
  
  
  													'''simple docstring'''
  
  													__SCREAMING_SNAKE_CASE								=      ['My hovercraft', 'is full of eels']
  													__SCREAMING_SNAKE_CASE								=      ['My hovercraft is full', ' of eels']
  													# S = 0, D = 0, I = 2, N = 28, CER = 2 / 28
  													# whitespace at the front of " of eels" will be strip during preporcessing
  													# so need to insert 2 whitespaces
  													__SCREAMING_SNAKE_CASE								=      cer.compute(predictions=_A   ,							references=_A   ,							concatenate_texts=_A	)
  													self.assertTrue(abs(char_error_rate - 0.0_7_1_4_2_8	) < 1e-6	)
  
  
  
  
  
  
  						def  _A			(					self	):
  
  
  
  
  
  
  
  													'''simple docstring'''
  
  													__SCREAMING_SNAKE_CASE								=      ['我能吞下玻璃而不伤身体']
  													__SCREAMING_SNAKE_CASE								=      [' 能吞虾玻璃而 不霜身体啦']
  													# S = 3, D = 2, I = 0, N = 11, CER = 5 / 11
  													__SCREAMING_SNAKE_CASE								=      cer.compute(predictions=_A   ,							references=_A	)
  													self.assertTrue(abs(char_error_rate - 0.4_5_4_5_4_5_4_5_4_5	) < 1e-6	)
  
  													__SCREAMING_SNAKE_CASE								=      ['我能吞下玻璃', '而不伤身体']
  													__SCREAMING_SNAKE_CASE								=      ['我    能 吞 下 玻 璃', '而不伤身体']
  													# S = 0, D = 5, I = 0, N = 11, CER = 5 / 11
  													__SCREAMING_SNAKE_CASE								=      cer.compute(predictions=_A   ,							references=_A	)
  													self.assertTrue(abs(char_error_rate - 0.4_5_4_5_4_5_4_5_4_5_4_5	) < 1e-6	)
  
  													__SCREAMING_SNAKE_CASE								=      ['我能吞下玻璃而不伤身体']
  													__SCREAMING_SNAKE_CASE								=      cer.compute(predictions=_A   ,							references=_A	)
  													self.assertFalse(_A   ,							0.0	)
  
  
  
  
  
  
  						def  _A			(					self	):
  
  
  
  
  
  
  
  													'''simple docstring'''
  
  													__SCREAMING_SNAKE_CASE								=      ['']
  													__SCREAMING_SNAKE_CASE								=      ['Hypothesis']
  													with self.assertRaises(_A	):
  																				cer.compute(predictions=_A   ,							references=_A	)
  
  
  if __name__ == "__main__":
  			unittest.main()
  
  
  
  
  
  
  