

from __future__ import annotations

from typing import Any







def _a					(			*SCREAMING_SNAKE_CASE						:     Dict						)       ->       list[list[int]]:

 """simple docstring"""






 if all(_check_not_integer(__lowerCAmelCase						) for m in matrix_s						):
  for i in matrix_s[1:]:
   _verify_matrix_sizes(matrix_s[0]       ,   __lowerCAmelCase						)
  return [[sum(__lowerCAmelCase						) for t in zip(*__lowerCAmelCase						)] for m in zip(*__lowerCAmelCase						)]
 raise TypeError('Expected a matrix, got int/list instead'						)







def _a					(			SCREAMING_SNAKE_CASE						:     Optional[Any]       ,   SCREAMING_SNAKE_CASE						:     Union[str, Any]						)       ->       list[list[int]]:

 """simple docstring"""






 if (
     _check_not_integer(__lowerCAmelCase						)
     and _check_not_integer(__lowerCAmelCase						)
     and _verify_matrix_sizes(__lowerCAmelCase       ,   __lowerCAmelCase						)
 ):
  return [[i - j for i, j in zip(*__lowerCAmelCase						)] for m in zip(__lowerCAmelCase       ,   __lowerCAmelCase						)]
 raise TypeError('Expected a matrix, got int/list instead'						)







def _a					(			SCREAMING_SNAKE_CASE						:     int       ,   SCREAMING_SNAKE_CASE						:     int						)       ->       list[list[float]]:

 """simple docstring"""






 return [[x * n for x in row] for row in matrix]







def _a					(			SCREAMING_SNAKE_CASE						:     str       ,   SCREAMING_SNAKE_CASE						:     int						)       ->       list[list[int]]:

 """simple docstring"""






 if _check_not_integer(__lowerCAmelCase						) and _check_not_integer(__lowerCAmelCase						):
  __lowerCAmelCase      ,				__lowerCAmelCase:  Tuple        = _verify_matrix_sizes(__lowerCAmelCase       ,   __lowerCAmelCase						)

 if cols[0] != rows[1]:
  __lowerCAmelCase:  Optional[Any]        = (
      'Cannot multiply matrix of dimensions '
      f'''({rows[0]},{cols[0]}) and ({rows[1]},{cols[1]})'''
  )
  raise ValueError(__lowerCAmelCase						)
 return [
     [sum(m * n for m, n in zip(__lowerCAmelCase       ,   __lowerCAmelCase						)						) for j in zip(*__lowerCAmelCase						)] for i in matrix_a
 ]







def _a					(			SCREAMING_SNAKE_CASE						:     Any						)       ->       list[list[int]]:

 """simple docstring"""






 __lowerCAmelCase:  Optional[Any]        = int(__lowerCAmelCase						)
 return [[int(row == column						) for column in range(__lowerCAmelCase						)] for row in range(__lowerCAmelCase						)]







def _a					(			SCREAMING_SNAKE_CASE						:     Union[str, Any]       ,   SCREAMING_SNAKE_CASE						:     Tuple = True						)       ->       list[list[int]] | map[list[int]]:

 """simple docstring"""






 if _check_not_integer(__lowerCAmelCase						):
  if return_map:
   return map(__lowerCAmelCase       ,   zip(*__lowerCAmelCase						)						)
  else:
   return list(map(__lowerCAmelCase       ,   zip(*__lowerCAmelCase						)						)						)
 raise TypeError('Expected a matrix, got int/list instead'						)







def _a					(			SCREAMING_SNAKE_CASE						:     Union[str, Any]       ,   SCREAMING_SNAKE_CASE						:     Optional[Any]       ,   SCREAMING_SNAKE_CASE						:     Any						)       ->       list[list[int]]:

 """simple docstring"""






 __lowerCAmelCase:  List[str]        = matrix[:row] + matrix[row + 1 :]
 return [row[:column] + row[column + 1 :] for row in minor]







def _a					(			SCREAMING_SNAKE_CASE						:     str						)       ->       Any:

 """simple docstring"""






 if len(__lowerCAmelCase						) == 1:
  return matrix[0][0]

 return sum(
     x * determinant(minor(__lowerCAmelCase       ,   0       ,   __lowerCAmelCase						)						) * (-1) ** i
     for i, x in enumerate(matrix[0]						)						)







def _a					(			SCREAMING_SNAKE_CASE						:     int						)       ->       list[list[float]] | None:

 """simple docstring"""






 __lowerCAmelCase:  List[str]        = determinant(__lowerCAmelCase						)
 if det == 0:
  return None

 __lowerCAmelCase:  int        = [
     [determinant(minor(__lowerCAmelCase       ,   __lowerCAmelCase       ,   __lowerCAmelCase						)						) for j in range(len(__lowerCAmelCase						)						)]
     for i in range(len(__lowerCAmelCase						)						)
 ]

 __lowerCAmelCase:  Optional[Any]        = [
     [x * (-1) ** (row + col) for col, x in enumerate(matrix_minor[row]						)]
     for row in range(len(__lowerCAmelCase						)						)
 ]
 __lowerCAmelCase:  Optional[int]        = list(transpose(__lowerCAmelCase						)						)
 return scalar_multiply(__lowerCAmelCase       ,   1 / det						)







def _a					(			SCREAMING_SNAKE_CASE						:     Union[str, Any]						)       ->       bool:

 """simple docstring"""






 return not isinstance(__lowerCAmelCase       ,   __lowerCAmelCase						) and not isinstance(matrix[0]       ,   __lowerCAmelCase						)







def _a					(			SCREAMING_SNAKE_CASE						:     Dict						)       ->       tuple[int, int]:

 """simple docstring"""






 return len(__lowerCAmelCase						), len(matrix[0]						)







def _a					(			SCREAMING_SNAKE_CASE						:     Optional[int]       ,   SCREAMING_SNAKE_CASE						:     Tuple						)       ->       tuple[tuple[int, int], tuple[int, int]]:

 """simple docstring"""






 __lowerCAmelCase:  Dict        = _shape(__lowerCAmelCase						) + _shape(__lowerCAmelCase						)
 if shape[0] != shape[3] or shape[1] != shape[2]:
  __lowerCAmelCase:  str        = (
      'operands could not be broadcast together with shape '
      f'''({shape[0], shape[1]}), ({shape[2], shape[3]})'''
  )
  raise ValueError(__lowerCAmelCase						)
 return (shape[0], shape[2]), (shape[1], shape[3])







def _a					(			)       ->       None:

 """simple docstring"""






 __lowerCAmelCase:  Optional[Any]        = [[12, 10], [3, 9]]
 __lowerCAmelCase:  Any        = [[3, 4], [7, 4]]
 __lowerCAmelCase:  Any        = [[11, 12, 13, 14], [21, 22, 23, 24], [31, 32, 33, 34], [41, 42, 43, 44]]
 __lowerCAmelCase:  List[str]        = [[3, 0, 2], [2, 0, -2], [0, 1, 1]]
 print(f'''Add Operation, {add(__lowerCAmelCase       ,   __lowerCAmelCase						) = } \n'''						)
 print(
     f'''Multiply Operation, {multiply(__lowerCAmelCase       ,   __lowerCAmelCase						) = } \n'''       ,   )
 print(f'''Identity: {identity(5						)}\n'''						)
 print(f'''Minor of {matrix_c} = {minor(__lowerCAmelCase       ,   1       ,   2						)} \n'''						)
 print(f'''Determinant of {matrix_b} = {determinant(__lowerCAmelCase						)} \n'''						)
 print(f'''Inverse of {matrix_d} = {inverse(__lowerCAmelCase						)}\n'''						)


if __name__ == "__main__":
  import doctest

  doctest.testmod()
  main()













import json
import os
import unittest

from transformers.models.gpt_neox_japanese.tokenization_gpt_neox_japanese import (
    VOCAB_FILES_NAMES,
    GPTNeoXJapaneseTokenizer,
)
from transformers.testing_utils import require_tokenizers, slow

from ...test_tokenization_common import TokenizerTesterMixin





@require_tokenizers
class __lowerCamelCase					( snake_case__	,			unittest.TestCase):





	"""simple docstring"""






	UpperCamelCase__								= GPTNeoXJapaneseTokenizer
	UpperCamelCase__								= False
	UpperCamelCase__								= {"do_clean_text": False, "add_prefix_space": False}

	def 			UpperCamelCase       (				self       ):
							"""simple docstring"""







							super().setUp()

							_UpperCAmelCase							   =     [
							    'こん',
							    'こんに',
							    'にちは',
							    'ばんは',
							    '世界,㔺界',
							    '、',
							    '。',
							    '<BR>',
							    '<SP>',
							    '<TAB>',
							    '<URL>',
							    '<EMAIL>',
							    '<TEL>',
							    '<DATE>',
							    '<PRICE>',
							    '<BLOCK>',
							    '<KIGOU>',
							    '<U2000U2BFF>',
							    '<|emoji1|>',
							    '<unk>',
							    '<|startoftext|>',
							    '<|endoftext|>',
							]
							_UpperCAmelCase							   =     {'emoji': {'\ud83d\ude00': '<|emoji1|>'}, 'emoji_inv': {'<|emoji1|>': '\ud83d\ude00'}}  # 😀
							_UpperCAmelCase							   =     {'unk_token': '<unk>'}

							_UpperCAmelCase							   =     os.path.join(self.tmpdirname			,       VOCAB_FILES_NAMES['vocab_file']       )
							_UpperCAmelCase							   =     os.path.join(self.tmpdirname			,       VOCAB_FILES_NAMES['emoji_file']       )
							with open(self.vocab_file			,       'w'			,       encoding='utf-8'       ) as vocab_writer:
													vocab_writer.write(''.join([x + '\n' for x in vocab_tokens]       )       )
							with open(self.emoji_file			,       'w'       ) as emoji_writer:
													emoji_writer.write(json.dumps(UpperCAmelCase       )       )

	def 			UpperCamelCase       (				self			,       **UpperCAmelCase       ):
							"""simple docstring"""







							kwargs.update(self.special_tokens_map       )
							return GPTNeoXJapaneseTokenizer.from_pretrained(self.tmpdirname			,       **UpperCAmelCase       )

	def 			UpperCamelCase       (				self			,       UpperCAmelCase       ):
							"""simple docstring"""







							_UpperCAmelCase							   =     'こんにちは、世界。 \nこんばんは、㔺界。😀'
							_UpperCAmelCase							   =     'こんにちは、世界。 \nこんばんは、世界。😀'
							return input_text, output_text

	def 			UpperCamelCase       (				self			,       UpperCAmelCase       ):
							"""simple docstring"""







							_UpperCAmelCase   ,					_UpperCAmelCase							   =     self.get_input_output_texts(UpperCAmelCase       )
							_UpperCAmelCase							   =     tokenizer.encode(UpperCAmelCase			,       add_special_tokens=UpperCAmelCase       )
							_UpperCAmelCase							   =     tokenizer.decode(UpperCAmelCase			,       clean_up_tokenization_spaces=UpperCAmelCase       )
							return text, ids

	def 			UpperCamelCase       (				self       ):
							"""simple docstring"""







							pass  # TODO add if relevant

	def 			UpperCamelCase       (				self       ):
							"""simple docstring"""







							pass  # TODO add if relevant

	def 			UpperCamelCase       (				self       ):
							"""simple docstring"""







							pass  # TODO add if relevant

	def 			UpperCamelCase       (				self       ):
							"""simple docstring"""







							_UpperCAmelCase							   =     self.get_tokenizer()

							# Testing tokenization
							_UpperCAmelCase							   =     'こんにちは、世界。　こんばんは、㔺界。'
							_UpperCAmelCase							   =     ['こん', 'にちは', '、', '世界', '。', '<SP>', 'こん', 'ばんは', '、', '㔺界', '。']
							_UpperCAmelCase							   =     tokenizer.tokenize(UpperCAmelCase       )
							self.assertListEqual(UpperCAmelCase			,       UpperCAmelCase       )

							# Testing conversion to ids without special tokens
							_UpperCAmelCase							   =     [0, 2, 5, 4, 6, 8, 0, 3, 5, 4, 6]
							_UpperCAmelCase							   =     tokenizer.convert_tokens_to_ids(UpperCAmelCase       )
							self.assertListEqual(UpperCAmelCase			,       UpperCAmelCase       )

							# Testing conversion to ids with special tokens
							_UpperCAmelCase							   =     tokens + [tokenizer.unk_token]
							_UpperCAmelCase							   =     [0, 2, 5, 4, 6, 8, 0, 3, 5, 4, 6, 19]
							_UpperCAmelCase							   =     tokenizer.convert_tokens_to_ids(UpperCAmelCase       )
							self.assertListEqual(UpperCAmelCase			,       UpperCAmelCase       )

	@slow
	def 			UpperCamelCase       (				self       ):
							"""simple docstring"""







							_UpperCAmelCase							   =     self.tokenizer_class.from_pretrained('abeja/gpt-neox-japanese-2.7b'       )

							_UpperCAmelCase							   =     tokenizer.encode('ありがとう。'			,       add_special_tokens=UpperCAmelCase       )
							_UpperCAmelCase							   =     tokenizer.encode('どういたしまして。'			,       add_special_tokens=UpperCAmelCase       )

							_UpperCAmelCase							   =     tokenizer.build_inputs_with_special_tokens(UpperCAmelCase       )
							_UpperCAmelCase							   =     tokenizer.build_inputs_with_special_tokens(UpperCAmelCase			,       UpperCAmelCase       )

							assert encoded_sentence == ids_a
							assert encoded_pair == ids_a + ids_a

	def 			UpperCamelCase       (				self       ):
							"""simple docstring"""







							pass

	def 			UpperCamelCase       (				self       ):
							"""simple docstring"""







							pass
