





import unittest

from transformers import AutoTokenizer, FalconConfig, is_torch_available
from transformers.testing_utils import require_torch, slow, torch_device

from ...generation.test_utils import GenerationTesterMixin
from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
							import torch

							from transformers import (
							    FalconForCausalLM,
							    FalconForQuestionAnswering,
							    FalconForSequenceClassification,
							    FalconForTokenClassification,
							    FalconModel,
							)
class     UpperCamelCase__					:






		'''simple docstring'''






		def __init__(							self,   snake_case__,   snake_case__=3,   snake_case__=7,   snake_case__=True,   snake_case__=True,   snake_case__=False,   snake_case__=True,   snake_case__=99,   snake_case__=32,   snake_case__=5,   snake_case__=4,   snake_case__=37,   snake_case__="gelu",   snake_case__=0.1,   snake_case__=0.1,   snake_case__=5_12,   snake_case__=16,   snake_case__=2,   snake_case__=0.02,   snake_case__=3,   snake_case__=4,   snake_case__=None,   )       -> Optional[int]:






									"""simple docstring"""
									lowercase_	:   Tuple  				=     parent
									lowercase_	:   Tuple  				=     batch_size
									lowercase_	:   List[str]  				=     seq_length
									lowercase_	:   int  				=     is_training
									lowercase_	:   Any  				=     use_input_mask
									lowercase_	:   List[Any]  				=     use_token_type_ids
									lowercase_	:   Union[str, Any]  				=     use_labels
									lowercase_	:   Any  				=     vocab_size
									lowercase_	:   Any  				=     hidden_size
									lowercase_	:   str  				=     num_hidden_layers
									lowercase_	:   Optional[int]  				=     num_attention_heads
									lowercase_	:   List[str]  				=     intermediate_size
									lowercase_	:   Optional[int]  				=     hidden_act
									lowercase_	:   Any  				=     hidden_dropout_prob
									lowercase_	:   Dict  				=     attention_probs_dropout_prob
									lowercase_	:   Optional[int]  				=     max_position_embeddings
									lowercase_	:   str  				=     type_vocab_size
									lowercase_	:   List[str]  				=     type_sequence_label_size
									lowercase_	:   List[str]  				=     initializer_range
									lowercase_	:   Dict  				=     num_labels
									lowercase_	:   Union[str, Any]  				=     num_choices
									lowercase_	:   Union[str, Any]  				=     scope






		def 						snake_case__				(							self  )       -> int:






									"""simple docstring"""
									lowercase_	:   List[Any]  				=     ids_tensor([self.batch_size, self.seq_length],   self.vocab_size  )

									lowercase_	:   int  				=     None
									if self.use_input_mask:
																lowercase_	:   List[Any]  				=     random_attention_mask([self.batch_size, self.seq_length]  )

									lowercase_	:   Optional[Any]  				=     None

									lowercase_	:   Any  				=     None
									lowercase_	:   str  				=     None
									lowercase_	:   str  				=     None
									if self.use_labels:
																lowercase_	:   Optional[int]  				=     ids_tensor([self.batch_size],   self.type_sequence_label_size  )
																lowercase_	:   Dict  				=     ids_tensor([self.batch_size, self.seq_length],   self.num_labels  )
																lowercase_	:   int  				=     ids_tensor([self.batch_size],   self.num_choices  )

									lowercase_	:   Tuple  				=     self.get_config()

									return config, input_ids, token_type_ids, input_mask, sequence_labels, token_labels, choice_labels






		def 						snake_case__				(							self  )       -> List[Any]:






									"""simple docstring"""
									return FalconConfig(
									    vocab_size=self.vocab_size,   hidden_size=self.hidden_size,   num_hidden_layers=self.num_hidden_layers,   num_attention_heads=self.num_attention_heads,   intermediate_size=self.intermediate_size,   hidden_act=self.hidden_act,   hidden_dropout_prob=self.hidden_dropout_prob,   attention_probs_dropout_prob=self.attention_probs_dropout_prob,   max_position_embeddings=self.max_position_embeddings,   type_vocab_size=self.type_vocab_size,   is_decoder=snake_case__,   initializer_range=self.initializer_range,   pad_token_id=1,   new_decoder_architecture=snake_case__,   )






		def 						snake_case__				(							self,   snake_case__,   snake_case__,   snake_case__,   snake_case__,   snake_case__,   snake_case__,   snake_case__  )       -> Tuple:






									"""simple docstring"""
									lowercase_	:   Optional[Any]  				=     FalconModel(config=snake_case__  )
									model.to(snake_case__  )
									model.eval()
									lowercase_	:   Dict  				=     model(snake_case__,   attention_mask=snake_case__  )
									lowercase_	:   int  				=     model(snake_case__  )
									self.parent.assertEqual(result.last_hidden_state.shape,   (self.batch_size, self.seq_length, self.hidden_size)  )






		def 						snake_case__				(							self,   snake_case__,   snake_case__,   snake_case__,   snake_case__,   snake_case__,   snake_case__,   snake_case__,   snake_case__,   snake_case__,   )       -> Tuple:






									"""simple docstring"""
									lowercase_	:   Optional[Any]  				=     True
									lowercase_	:   Tuple  				=     FalconModel(snake_case__  )
									model.to(snake_case__  )
									model.eval()
									lowercase_	:   str  				=     model(
									    snake_case__,   attention_mask=snake_case__,   encoder_hidden_states=snake_case__,   encoder_attention_mask=snake_case__,   )
									lowercase_	:   str  				=     model(
									    snake_case__,   attention_mask=snake_case__,   encoder_hidden_states=snake_case__,   )
									lowercase_	:   Optional[Any]  				=     model(snake_case__,   attention_mask=snake_case__  )
									self.parent.assertEqual(result.last_hidden_state.shape,   (self.batch_size, self.seq_length, self.hidden_size)  )






		def 						snake_case__				(							self,   snake_case__,   snake_case__,   snake_case__,   snake_case__,   snake_case__,   snake_case__,   snake_case__,   snake_case__,   snake_case__,   )       -> Optional[Any]:






									"""simple docstring"""
									lowercase_	:   Any  				=     FalconForCausalLM(config=snake_case__  )
									model.to(snake_case__  )
									model.eval()
									lowercase_	:   str  				=     model(snake_case__,   attention_mask=snake_case__,   labels=snake_case__  )
									self.parent.assertEqual(result.logits.shape,   (self.batch_size, self.seq_length, self.vocab_size)  )






		def 						snake_case__				(							self,   snake_case__,   snake_case__,   snake_case__,   snake_case__,   snake_case__,   snake_case__,   snake_case__,   snake_case__,   snake_case__,   )       -> int:






									"""simple docstring"""
									lowercase_	:   List[str]  				=     True
									lowercase_	:   List[Any]  				=     True
									lowercase_	:   Optional[Any]  				=     FalconForCausalLM(config=snake_case__  )
									model.to(snake_case__  )
									model.eval()

									# first forward pass
									lowercase_	:   List[Any]  				=     model(
									    snake_case__,   attention_mask=snake_case__,   encoder_hidden_states=snake_case__,   encoder_attention_mask=snake_case__,   use_cache=snake_case__,   )
									lowercase_	:   int  				=     outputs.past_key_values

									# create hypothetical multiple next token and extent to next_input_ids
									lowercase_	:   Optional[int]  				=     ids_tensor((self.batch_size, 3),   config.vocab_size  )
									lowercase_	:   Dict  				=     ids_tensor((self.batch_size, 3),   vocab_size=2  )

									# append to next input_ids and
									lowercase_	:   List[str]  				=     torch.cat([input_ids, next_tokens],   dim=-1  )
									lowercase_	:   str  				=     torch.cat([input_mask, next_mask],   dim=-1  )

									lowercase_	:   List[Any]  				=     model(
									    snake_case__,   attention_mask=snake_case__,   encoder_hidden_states=snake_case__,   encoder_attention_mask=snake_case__,   output_hidden_states=snake_case__,   )["""hidden_states"""][0]
									lowercase_	:   List[Any]  				=     model(
									    snake_case__,   attention_mask=snake_case__,   encoder_hidden_states=snake_case__,   encoder_attention_mask=snake_case__,   past_key_values=snake_case__,   output_hidden_states=snake_case__,   )["""hidden_states"""][0]

									# select random slice
									lowercase_	:   List[Any]  				=     ids_tensor((1,),   output_from_past.shape[-1]  ).item()
									lowercase_	:   Any  				=     output_from_no_past[:, -3:, random_slice_idx].detach()
									lowercase_	:   int  				=     output_from_past[:, :, random_slice_idx].detach()

									self.parent.assertTrue(output_from_past_slice.shape[1] == next_tokens.shape[1]  )

									# test that outputs are equal for slice
									self.parent.assertTrue(torch.allclose(snake_case__,   snake_case__,   atol=1E-3  )  )






		def 						snake_case__				(							self  )       -> Any:






									"""simple docstring"""
									lowercase_	:   Tuple  				=     self.prepare_config_and_inputs()
									(
									    (
									    lowercase_
									)				,		(
									    lowercase_
									)				,		(
									    lowercase_
									)				,		(
									    lowercase_
									)				,		(
									    lowercase_
									)				,		(
									    lowercase_
									)				,		(
									    lowercase_
									)				,		
									)	:   Union[str, Any]  				=     config_and_inputs
									lowercase_	:   List[Any]  				=     {"""input_ids""": input_ids, """attention_mask""": input_mask}
									return config, inputs_dict




@require_torch
class     UpperCamelCase__					(     lowerCamelCase__				, lowerCamelCase__				, lowerCamelCase__				, unittest.TestCase				):






		'''simple docstring'''






		__a       :       int       =	(
		    (
		        FalconModel,
		        FalconForCausalLM,
		        FalconForSequenceClassification,
		        FalconForTokenClassification,
		        FalconForQuestionAnswering,
		    )
		    if is_torch_available()
		    else ()
		)
		__a       :       Tuple       =	(FalconForCausalLM,) if is_torch_available() else ()
		__a       :       Union[str, Any]       =	(
		    {
		        """feature-extraction""": FalconModel,
		        """text-classification""": FalconForSequenceClassification,
		        """text-generation""": FalconForCausalLM,
		        """question-answering""": FalconForQuestionAnswering,
		        """token-classification""": FalconForTokenClassification,
		        """zero-shot""": FalconForSequenceClassification,
		    }
		    if is_torch_available()
		    else {}
		)
		__a       :       int       =	False
		__a       :       List[Any]       =	False






		def 						snake_case__				(							self  )       -> Optional[int]:






									"""simple docstring"""
									lowercase_	:   Any  				=     FalconModelTester(self  )
									lowercase_	:   Union[str, Any]  				=     ConfigTester(self,   config_class=snake_case__,   hidden_size=37  )






		def 						snake_case__				(							self  )       -> Tuple:






									"""simple docstring"""
									self.config_tester.run_common_tests()






		def 						snake_case__				(							self  )       -> Any:






									"""simple docstring"""
									lowercase_	:   int  				=     self.model_tester.prepare_config_and_inputs()
									self.model_tester.create_and_check_model(*snake_case__  )






		def 						snake_case__				(							self  )       -> Optional[Any]:






									"""simple docstring"""
									lowercase_				,		*lowercase_	:   str  				=     self.model_tester.prepare_config_and_inputs()
									for alibi in [True, False]:
																lowercase_	:   List[Any]  				=     alibi
																self.model_tester.create_and_check_model(snake_case__,   *snake_case__  )






		def 						snake_case__				(							self  )       -> Dict:






									"""simple docstring"""
									lowercase_				,		lowercase_	:   Dict  				=     self.model_tester.prepare_config_and_inputs_for_common()
									lowercase_	:   Tuple  				=     3
									lowercase_	:   str  				=     input_dict["""input_ids"""]
									lowercase_	:   int  				=     input_ids.ne(1  ).to(snake_case__  )
									lowercase_	:   Any  				=     ids_tensor([self.model_tester.batch_size],   self.model_tester.type_sequence_label_size  )
									lowercase_	:   List[Any]  				=     FalconForSequenceClassification(snake_case__  )
									model.to(snake_case__  )
									model.eval()
									lowercase_	:   Tuple  				=     model(snake_case__,   attention_mask=snake_case__,   labels=snake_case__  )
									self.assertEqual(result.logits.shape,   (self.model_tester.batch_size, self.model_tester.num_labels)  )






		def 						snake_case__				(							self  )       -> int:






									"""simple docstring"""
									lowercase_				,		lowercase_	:   List[Any]  				=     self.model_tester.prepare_config_and_inputs_for_common()
									lowercase_	:   Optional[Any]  				=     3
									lowercase_	:   int  				=     """single_label_classification"""
									lowercase_	:   Tuple  				=     input_dict["""input_ids"""]
									lowercase_	:   Tuple  				=     input_ids.ne(1  ).to(snake_case__  )
									lowercase_	:   Optional[int]  				=     ids_tensor([self.model_tester.batch_size],   self.model_tester.type_sequence_label_size  )
									lowercase_	:   Tuple  				=     FalconForSequenceClassification(snake_case__  )
									model.to(snake_case__  )
									model.eval()
									lowercase_	:   List[str]  				=     model(snake_case__,   attention_mask=snake_case__,   labels=snake_case__  )
									self.assertEqual(result.logits.shape,   (self.model_tester.batch_size, self.model_tester.num_labels)  )






		def 						snake_case__				(							self  )       -> List[str]:






									"""simple docstring"""
									lowercase_				,		lowercase_	:   List[str]  				=     self.model_tester.prepare_config_and_inputs_for_common()
									lowercase_	:   Tuple  				=     input_dict["""input_ids"""]
									lowercase_	:   Any  				=     FalconForCausalLM(snake_case__  )
									model.to(snake_case__  )
									model.eval()
									lowercase_	:   Tuple  				=     model(snake_case__,   use_cache=snake_case__  )
									lowercase_	:   Optional[int]  				=     input_ids.shape[0]
									lowercase_	:   Optional[int]  				=     model._convert_to_rw_cache(result.past_key_values  )
									lowercase_	:   int  				=     model._convert_cache_to_standard_format(snake_case__,   snake_case__  )
									for layer in range(len(snake_case__  )  ):
																for tensor_idx in range(2  ):
																							self.assertTrue(rw_cache[layer][tensor_idx].ndim == 3  )
																							self.assertTrue(result.past_key_values[layer][tensor_idx].ndim == 4  )
																							self.assertTrue(
																							    torch.all(result.past_key_values[layer][tensor_idx] == standard_cache[layer][tensor_idx]  )  )






		def 						snake_case__				(							self  )       -> int:






									"""simple docstring"""
									lowercase_				,		lowercase_	:   List[Any]  				=     self.model_tester.prepare_config_and_inputs_for_common()
									lowercase_	:   Tuple  				=     3
									lowercase_	:   str  				=     """multi_label_classification"""
									lowercase_	:   str  				=     input_dict["""input_ids"""]
									lowercase_	:   Dict  				=     input_ids.ne(1  ).to(snake_case__  )
									lowercase_	:   Dict  				=     ids_tensor(
									    [self.model_tester.batch_size, config.num_labels],   self.model_tester.type_sequence_label_size  ).to(torch.float  )
									lowercase_	:   Optional[int]  				=     FalconForSequenceClassification(snake_case__  )
									model.to(snake_case__  )
									model.eval()
									lowercase_	:   Optional[int]  				=     model(snake_case__,   attention_mask=snake_case__,   labels=snake_case__  )
									self.assertEqual(result.logits.shape,   (self.model_tester.batch_size, self.model_tester.num_labels)  )






		def 						snake_case__				(							self  )       -> Tuple:






									"""simple docstring"""
									# Falcon can have different numbers of KV-heads than the number of query heads, so we need
									# to override this test to use the right head counts.
									for model_class in self.all_generative_model_classes:
																lowercase_				,		lowercase_	:   Union[str, Any]  				=     self.model_tester.prepare_config_and_inputs_for_common()

																# If it doesn't support cache, pass the test
																if not hasattr(snake_case__,   """use_cache"""  ):
																							return

																lowercase_	:   Optional[int]  				=     model_class(snake_case__  ).to(snake_case__  )
																if "use_cache" not in inputs:
																							lowercase_	:   Dict  				=     True
																lowercase_	:   Optional[Any]  				=     model(**snake_case__  )

																# If "past_key_values" is not returned, pass the test (e.g. RWKV uses a different cache name and format)
																if "past_key_values" not in outputs:
																							return

																lowercase_	:   str  				=     (
																    getattr(snake_case__,   """decoder_layers""",   snake_case__  )
																    or getattr(snake_case__,   """num_decoder_layers""",   snake_case__  )
																    or config.num_hidden_layers
																)
																lowercase_	:   Dict  				=     getattr(snake_case__,   """num_kv_heads""",   config.num_attention_heads  )
																lowercase_	:   int  				=     getattr(snake_case__,   """d_model""",   config.hidden_size  )
																lowercase_	:   List[Any]  				=     embed_dim // num_attention_heads

																lowercase_	:   List[Any]  				=     outputs["""past_key_values"""]
																self.assertEqual(len(snake_case__  ),   snake_case__  )

																lowercase_				,		lowercase_	:   int  				=     inputs["""input_ids"""].shape
																for i in range(snake_case__  ):
																							if config.new_decoder_architecture:
																														lowercase_	:   Optional[Any]  				=     config.num_attention_heads
																							elif config.multi_query:
																														lowercase_	:   Union[str, Any]  				=     1
																							self.assertEqual(len(past_kv[0]  ),   2  )  # K V for the decoder = 2
																							self.assertEqual(
																							    past_kv[i][0].shape,   (batch_size, num_attention_heads, seq_length, per_head_embed_dim)  )
																							self.assertEqual(
																							    past_kv[i][1].shape,   (batch_size, num_attention_heads, seq_length, per_head_embed_dim)  )




@require_torch
class     UpperCamelCase__					(     unittest.TestCase				):






		'''simple docstring'''






		@slow
		def 						snake_case__				(							self  )       -> Dict:






									"""simple docstring"""
									lowercase_	:   Optional[Any]  				=     AutoTokenizer.from_pretrained("""Rocketknight1/falcon-rw-1b"""  )
									lowercase_	:   Tuple  				=     FalconForCausalLM.from_pretrained("""Rocketknight1/falcon-rw-1b"""  )
									model.eval()
									model.to(snake_case__  )
									lowercase_	:   Optional[int]  				=     tokenizer("""My favorite food is""",   return_tensors="""pt"""  ).to(snake_case__  )

									lowercase_	:   List[str]  				=     (
									    """My favorite food is pizza. I love it so much that I have a pizza party every year for my birthday."""
									)

									lowercase_	:   str  				=     model.generate(**snake_case__,   do_sample=snake_case__,   max_new_tokens=19  )
									lowercase_	:   Optional[int]  				=     tokenizer.batch_decode(snake_case__  )[0]

									self.assertEqual(snake_case__,   snake_case__  )






		@slow
		def 						snake_case__				(							self  )       -> Optional[Any]:






									"""simple docstring"""
									# The big models are way too big for the CI, so we use tiny random models that resemble their
									# architectures but with much smaller and fewer layers
									for repo in ["Rocketknight1/tiny-random-falcon-7b", "Rocketknight1/tiny-random-falcon-40b"]:
																lowercase_	:   Dict  				=     AutoTokenizer.from_pretrained(snake_case__  )
																lowercase_	:   Optional[Any]  				=     FalconForCausalLM.from_pretrained(snake_case__  )
																model.eval()
																model.to(snake_case__  )
																lowercase_	:   str  				=     tokenizer("""My favorite food is""",   return_tensors="""pt"""  ).to(snake_case__  )

																# We just test that these run without errors - the models are randomly initialized
																# and so the actual text outputs will be garbage
																model.generate(**snake_case__,   do_sample=snake_case__,   max_new_tokens=4  )
																model.generate(**snake_case__,   do_sample=snake_case__,   max_new_tokens=4  )
																model.generate(**snake_case__,   num_beams=2,   max_new_tokens=4  )






		@slow
		def 						snake_case__				(							self  )       -> Optional[Any]:






									"""simple docstring"""
									# The big models are way too big for the CI, so we use tiny random models that resemble their
									# architectures but with much smaller and fewer layers
									with torch.no_grad():
																for repo in [
																    "Rocketknight1/falcon-rw-1b",
																    "Rocketknight1/tiny-random-falcon-7b",
																    "Rocketknight1/tiny-random-falcon-40b",
																]:
																							lowercase_	:   str  				=     AutoTokenizer.from_pretrained(snake_case__  )
																							lowercase_	:   Dict  				=     FalconForCausalLM.from_pretrained(snake_case__  )
																							model.eval()
																							model.to(device=snake_case__  )
																							lowercase_	:   Optional[int]  				=     tokenizer("""My favorite food is""",   return_tensors="""pt"""  ).to(snake_case__  )

																							# Test results are the same with and without cache
																							lowercase_	:   List[str]  				=     model.generate(**snake_case__,   do_sample=snake_case__,   max_new_tokens=20,   use_cache=snake_case__  )
																							lowercase_	:   Tuple  				=     model.generate(**snake_case__,   do_sample=snake_case__,   max_new_tokens=20,   use_cache=snake_case__  )
																							self.assertTrue((outputs_cache - outputs_no_cache).sum().item() == 0  )






def  __magic_name__  (				lowercase				)				-> list[list]:

							"""simple docstring"""



							lowercase_	:   int  				=     current_set.copy()
							for row_index, row in enumerate(lowercase				):
														lowercase_	:   Tuple  				=     row[0]
														for column_index, column in enumerate(lowercase				):
																					if magnitude == 0:
																												lowercase_	:   Optional[int]  				=     column
																												continue
																					lowercase_	:   List[str]  				=     column / magnitude
    # Subtract to cancel term
							lowercase_	:   List[str]  				=     current_set[0]
							lowercase_	:   Optional[int]  				=     [first_row]
							lowercase_	:   Optional[Any]  				=     current_set[1::]
							for row in current_set:
														lowercase_	:   Union[str, Any]  				=     []
														# If first term is 0, it is already in form we want, so we preserve it
														if row[0] == 0:
																					final_set.append(lowercase				)
																					continue
														for column_index in range(len(lowercase				)				):
																					temp_row.append(first_row[column_index] - row[column_index]				)
														final_set.append(lowercase				)
							# Create next recursion iteration set
							if len(final_set[0]				) != 3:
														lowercase_	:   Tuple  				=     final_set[0]
														lowercase_	:   Dict  				=     []
														lowercase_	:   Any  				=     []
														for row in final_set[1::]:
																					current_first_column.append(row[0]				)
																					next_iteration.append(row[1::]				)
														lowercase_	:   Optional[Any]  				=     simplify(lowercase				)
														for i in range(len(lowercase				)				):
																					resultant[i].insert(0				,       current_first_column[i]				)
														resultant.insert(0				,       lowercase				)
														lowercase_	:   Tuple  				=     resultant
							return final_set





def  __magic_name__  (				lowercase				)				-> list:

							"""simple docstring"""



							if len(lowercase				) == 0:
														raise IndexError("""solve_simultaneous() requires n lists of length n+1"""				)
							lowercase_	:   Tuple  				=     len(lowercase				) + 1
							if any(len(lowercase				) != _length for item in equations				):
														raise IndexError("""solve_simultaneous() requires n lists of length n+1"""				)
							for row in equations:
														if any(not isinstance(lowercase				,       (int, float)				) for column in row				):
																					raise ValueError("""solve_simultaneous() requires lists of integers"""				)
							if len(lowercase				) == 1:
														return [equations[0][-1] / equations[0][0]]
							lowercase_	:   List[str]  				=     equations.copy()
							if any(0 in row for row in data_set				):
														lowercase_	:   int  				=     data_set.copy()
														lowercase_	:   Dict  				=     []
														for row_index, row in enumerate(lowercase				):
																					if 0 not in row:
																												lowercase_	:   Dict  				=     data_set.pop(lowercase				)
																												break
														if not full_row:
																					raise ValueError("""solve_simultaneous() requires at least 1 full equation"""				)
														data_set.insert(0				,       lowercase				)
							lowercase_	:   Tuple  				=     data_set.copy()
							lowercase_	:   List[Any]  				=     simplify(lowercase				)
							lowercase_	:   Dict  				=     simplified[::-1]
							lowercase_	:   list  				=     []
							for row in simplified:
														lowercase_	:   Union[str, Any]  				=     row[-1]
														if not solutions:
																					if row[-2] == 0:
																												solutions.append(0				)
																												continue
																					solutions.append(current_solution / row[-2]				)
																					continue
														lowercase_	:   Any  				=     row.copy()[: len(lowercase				) - 1 :]
														while temp_row[0] == 0:
																					temp_row.pop(0				)
														if len(lowercase				) == 0:
																					solutions.append(0				)
																					continue
														lowercase_	:   Any  				=     temp_row[1::]
														lowercase_	:   Union[str, Any]  				=     temp_row[::-1]
														for column_index, column in enumerate(lowercase				):
																					current_solution -= column * solutions[column_index]
														solutions.append(lowercase				)
							lowercase_	:   Any  				=     []
							for item in solutions:
														final.append(float(round(lowercase				,       5				)				)				)
							return final[::-1]


if __name__ == "__main__":
							import doctest

							doctest.testmod()
							UpperCAmelCase_							=				[
							    [2, 1, 1, 1, 1, 4],
							    [1, 2, 1, 1, 1, 5],
							    [1, 1, 2, 1, 1, 6],
							    [1, 1, 1, 2, 1, 7],
							    [1, 1, 1, 1, 2, 8],
							]
							print(solve_simultaneous(eq))
							print(solve_simultaneous([[4, 2]]))