import timeit





class   lowerCAmelCase    :



     def __init__(       self					,   lowerCAmelCase__							):
            if isinstance(lowerCAmelCase__					,   lowerCAmelCase__							):  # Initializes a matrix identical to the one provided.
                   _A=						arg
                   _A=						len(lowerCAmelCase__							)
            else:  # Initializes a square matrix of the given size and set values to zero.
                   _A=						arg
                   _A=						[[0 for _ in range(self.n							)] for _ in range(self.n							)]





     def __mul__(       self					,   lowerCAmelCase__							):
            _A=						Matrix(self.n							)
            for i in range(self.n							):
                   for j in range(self.n							):
                          for k in range(self.n							):
                                 matrix.t[i][j] += self.t[i][k] * b.t[k][j]
            return matrix


def 				UpperCamelCase					(     lowerCAmelCase_							,       lowerCAmelCase_ )		->    str:




       '''simple docstring'''






       _A=						Matrix([[1, 0], [0, 1]] )
       while b > 0:
              if b & 1:
                     matrix *= a
              a *= a
              b >>= 1
       return matrix

def 				UpperCamelCase					(     lowerCAmelCase_							,       lowerCAmelCase_							,       lowerCAmelCase_ )		->    Dict:




       '''simple docstring'''






       if n == 1:
              return fa
       elif n == 2:
              return fa
       _A=						Matrix([[1, 1], [1, 0]] )
       _A=						modular_exponentiation(lowerCAmelCase_							,       n - 2 )
       return fa * matrix.t[0][0] + fa * matrix.t[0][1]

def 				UpperCamelCase					(     lowerCAmelCase_							,       lowerCAmelCase_							,       lowerCAmelCase_ )		->    Union[str, Any]:




       '''simple docstring'''






       if n == 1:
              return fa
       elif n == 2:
              return fa

       _A=						fa
       _A=						fa
       n -= 2

       while n > 0:
              _A,      _A=						fn_a + fn_a, fn_a
              n -= 1

       return fn_a

def 				UpperCamelCase					(     )		->    List[str]:




       '''simple docstring'''






       _A=						'\nfrom random import randint\nfrom __main__ import fibonacci_with_matrix_exponentiation\n'
       _A=						'fibonacci_with_matrix_exponentiation(randint(1,70000), 1, 1)'
       _A=						timeit.timeit(setup=lowerCAmelCase_							,       stmt=lowerCAmelCase_							,       number=1_00 )
       print('With matrix exponentiation the average execution time is '							,       exec_time / 1_00 )
       return exec_time

def 				UpperCamelCase					(     )		->    List[Any]:




       '''simple docstring'''






       _A=						'\nfrom random import randint\nfrom __main__ import simple_fibonacci\n'
       _A=						'simple_fibonacci(randint(1,70000), 1, 1)'
       _A=						timeit.timeit(setup=lowerCAmelCase_							,       stmt=lowerCAmelCase_							,       number=1_00 )
       print(
           'Without matrix exponentiation the average execution time is '							,       exec_time / 1_00 )
       return exec_time

def 				UpperCamelCase					(     )		->    int:




       '''simple docstring'''






       matrix_exponentiation_time()
       simple_fibonacci_time()


if __name__ == "__main__":
      main()
import os
import shutil
import unittest
from unittest.mock import patch

from transformers.testing_utils import CaptureStd, is_pt_tf_cross_test, require_torch





class   lowerCAmelCase    (       unittest.TestCase      ):



     @patch('sys.argv'					,   ['fakeprogrampath', 'env']							)
     def       a__	(       self							):
            # test transformers-cli env
            import transformers.commands.transformers_cli

            with CaptureStd() as cs:
                   transformers.commands.transformers_cli.main()
            self.assertIn('Python version'					,   cs.out							)
            self.assertIn('Platform'					,   cs.out							)
            self.assertIn('Using distributed or parallel set-up in script?'					,   cs.out							)



     @is_pt_tf_cross_test
     @patch(
         'sys.argv'					,   ['fakeprogrampath', 'pt-to-tf', '--model-name', 'hf-internal-testing/tiny-random-gptj', '--no-pr']							)
     def       a__	(       self							):
            import transformers.commands.transformers_cli

            shutil.rmtree('/tmp/hf-internal-testing/tiny-random-gptj'					,   ignore_errors=lowerCAmelCase__							)  # cleans potential past runs
            transformers.commands.transformers_cli.main()

            # The original repo has no TF weights -- if they exist, they were created by the CLI
            self.assertTrue(os.path.exists('/tmp/hf-internal-testing/tiny-random-gptj/tf_model.h5'							)							)



     @require_torch
     @patch('sys.argv'					,   ['fakeprogrampath', 'download', 'hf-internal-testing/tiny-random-gptj', '--cache-dir', '/tmp']							)
     def       a__	(       self							):
            import transformers.commands.transformers_cli

            # # remove any previously downloaded model to start clean
            shutil.rmtree('/tmp/models--hf-internal-testing--tiny-random-gptj'					,   ignore_errors=lowerCAmelCase__							)

            # run the command
            transformers.commands.transformers_cli.main()

            # check if the model files are downloaded correctly on /tmp/models--hf-internal-testing--tiny-random-gptj
            self.assertTrue(os.path.exists('/tmp/models--hf-internal-testing--tiny-random-gptj/blobs'							)							)
            self.assertTrue(os.path.exists('/tmp/models--hf-internal-testing--tiny-random-gptj/refs'							)							)
            self.assertTrue(os.path.exists('/tmp/models--hf-internal-testing--tiny-random-gptj/snapshots'							)							)





     @require_torch
     @patch(
         'sys.argv'					,   [
             'fakeprogrampath',
             'download',
             'hf-internal-testing/test_dynamic_model_with_tokenizer',
             '--trust-remote-code',
             '--cache-dir',
             '/tmp',
         ]					,   )
     def       a__	(       self							):
            import transformers.commands.transformers_cli

            # # remove any previously downloaded model to start clean
            shutil.rmtree('/tmp/models--hf-internal-testing--test_dynamic_model_with_tokenizer'					,   ignore_errors=lowerCAmelCase__							)

            # run the command
            transformers.commands.transformers_cli.main()

            # check if the model files are downloaded correctly on /tmp/models--hf-internal-testing--test_dynamic_model_with_tokenizer
            self.assertTrue(os.path.exists('/tmp/models--hf-internal-testing--test_dynamic_model_with_tokenizer/blobs'							)							)
            self.assertTrue(os.path.exists('/tmp/models--hf-internal-testing--test_dynamic_model_with_tokenizer/refs'							)							)
            self.assertTrue(
                os.path.exists('/tmp/models--hf-internal-testing--test_dynamic_model_with_tokenizer/snapshots'							)							)