






from __future__ import annotations

from typing import Any


def __A       ( *__lowerCAmelCase      )->    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       ( __lowerCAmelCase					,						__lowerCAmelCase      )->    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       ( __lowerCAmelCase					,						__lowerCAmelCase      )->    list[list[float]]:





						"""simple docstring"""



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


def __A       ( __lowerCAmelCase					,						__lowerCAmelCase      )->    list[list[int]]:





						"""simple docstring"""



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

						if cols[0] != rows[1]:
												_UpperCAmelCase							   =     (
												    '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       ( __lowerCAmelCase      )->    list[list[int]]:





						"""simple docstring"""



						_UpperCAmelCase							   =     int(__lowerCAmelCase      )
						return [[int(row == column      ) for column in range(__lowerCAmelCase      )] for row in range(__lowerCAmelCase      )]


def __A       ( __lowerCAmelCase					,						__lowerCAmelCase = 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       ( __lowerCAmelCase					,						__lowerCAmelCase					,						__lowerCAmelCase      )->    list[list[int]]:





						"""simple docstring"""



						_UpperCAmelCase							   =     matrix[:row] + matrix[row + 1 :]
						return [row[:column] + row[column + 1 :] for row in minor]


def __A       ( __lowerCAmelCase      )->    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       ( __lowerCAmelCase      )->    list[list[float]] | None:





						"""simple docstring"""



						_UpperCAmelCase							   =     determinant(__lowerCAmelCase      )
						if det == 0:
												return None

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

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


def __A       ( __lowerCAmelCase      )->    bool:





						"""simple docstring"""



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


def __A       ( __lowerCAmelCase      )->    tuple[int, int]:





						"""simple docstring"""



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


def __A       ( __lowerCAmelCase					,						__lowerCAmelCase      )->    tuple[tuple[int, int], tuple[int, int]]:





						"""simple docstring"""



						_UpperCAmelCase							   =     _shape(__lowerCAmelCase      ) + _shape(__lowerCAmelCase      )
						if shape[0] != shape[3] or shape[1] != shape[2]:
												_UpperCAmelCase							   =     (
												    '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"""



						_UpperCAmelCase							   =     [[12, 10], [3, 9]]
						_UpperCAmelCase							   =     [[3, 4], [7, 4]]
						_UpperCAmelCase							   =     [[11, 12, 13, 14], [21, 22, 23, 24], [31, 32, 33, 34], [41, 42, 43, 44]]
						_UpperCAmelCase							   =     [[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
