





import unittest

import numpy as np







def  _SCREAMING_SNAKE_CASE				(   a					,						a					,						a					,						a = None					,						)      ->      np.ndarray:
					__A	:						List[str]       =				np.shape(a  )
					__A	:						Union[str, Any]       =				np.shape(a  )
					__A	:						str       =				np.shape(a  )

					if shape_a[0] != shape_b[0]:
										__A	:						Dict       =				(
										    'Expected the same number of rows for A and B. '
										    F"""Instead found A of size {shape_a} and B of size {shape_b}"""
										)
										raise ValueError(a  )

					if shape_b[1] != shape_c[1]:
										__A	:						Any       =				(
										    'Expected the same number of columns for B and C. '
										    F"""Instead found B of size {shape_b} and C of size {shape_c}"""
										)
										raise ValueError(a  )

					__A	:						str       =				pseudo_inv
					if a_inv is None:
										try:
															__A	:						Any       =				np.linalg.inv(a  )
										except np.linalg.LinAlgError:
															raise ValueError(
															    'Input matrix A is not invertible. Cannot compute Schur complement.'  )

					return mat_c - mat_b.T @ a_inv @ mat_b





class 						_A(					unittest.TestCase   ):


				"""simple docstring"""


				def 					UpperCAmelCase_		(			self     ):
									__A	:						int       =				np.array([[1, 2, 1], [2, 1, 2], [3, 2, 4]]     )
									__A	:						Dict       =				np.array([[0, 3], [3, 0], [2, 3]]     )
									__A	:						str       =				np.array([[2, 1], [6, 3]]     )

									__A	:						Any       =				schur_complement(_A     ,					_A     ,					_A     )

									__A	:						int       =				np.block([[a, b], [b.T, c]]     )

									__A	:						List[Any]       =				np.linalg.det(_A     )
									__A	:						Optional[Any]       =				np.linalg.det(_A     )
									__A	:						List[str]       =				np.linalg.det(_A     )

									self.assertAlmostEqual(_A     ,					det_a * det_s     )



				def 					UpperCAmelCase_		(			self     ):
									__A	:						Optional[Any]       =				np.array([[1, 2, 1], [2, 1, 2], [3, 2, 4]]     )
									__A	:						Any       =				np.array([[0, 3], [3, 0], [2, 3]]     )
									__A	:						Tuple       =				np.array([[2, 1], [6, 3]]     )

									with self.assertRaises(_A     ):
														schur_complement(_A     ,					_A     ,					_A     )





				def 					UpperCAmelCase_		(			self     ):
									__A	:						List[Any]       =				np.array([[1, 2, 1], [2, 1, 2], [3, 2, 4]]     )
									__A	:						int       =				np.array([[0, 3], [3, 0], [2, 3]]     )
									__A	:						List[Any]       =				np.array([[2, 1, 3], [6, 3, 5]]     )

									with self.assertRaises(_A     ):
														schur_complement(_A     ,					_A     ,					_A     )


if __name__ == "__main__":
				import doctest

				doctest.testmod()
				unittest.main()











from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_torch_available,
)


UpperCAmelCase						:   Any			  =     {
    '''configuration_falcon''': ['''FALCON_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''FalconConfig'''],
}

try:
				if not is_torch_available():
								raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
				pass
else:
				UpperCAmelCase						:   Any			  =     [
				    '''FALCON_PRETRAINED_MODEL_ARCHIVE_LIST''',
				    '''FalconForCausalLM''',
				    '''FalconModel''',
				    '''FalconPreTrainedModel''',
				    '''FalconForSequenceClassification''',
				    '''FalconForTokenClassification''',
				    '''FalconForQuestionAnswering''',
				]


if TYPE_CHECKING:
				from .configuration_falcon import FALCON_PRETRAINED_CONFIG_ARCHIVE_MAP, FalconConfig

				try:
								if not is_torch_available():
												raise OptionalDependencyNotAvailable()
				except OptionalDependencyNotAvailable:
								pass
				else:
								from .modeling_falcon import (
								    FALCON_PRETRAINED_MODEL_ARCHIVE_LIST,
								    FalconForCausalLM,
								    FalconForQuestionAnswering,
								    FalconForSequenceClassification,
								    FalconForTokenClassification,
								    FalconModel,
								    FalconPreTrainedModel,
								)


else:
				import sys

				UpperCAmelCase						:   List[str]			  =     _LazyModule(__name__, globals()['''__file__'''], _import_structure, module_spec=__spec__)




