


import doctest
import glob
import importlib
import inspect
import os
import re
from contextlib import contextmanager
from functools import wraps
from unittest.mock import patch

import numpy as np
import pytest
from absl.testing import parameterized

import datasets
from datasets import load_metric

from .utils import for_all_test_methods, local, slow


# mark all tests as integration
__lowerCAmelCase		       =							pytest.mark.integration


__lowerCAmelCase		       =							{'''comet'''}
__lowerCAmelCase		       =							importlib.util.find_spec('''fairseq''') is not None

__lowerCAmelCase		       =							{'''code_eval'''}
__lowerCAmelCase		       =							os.name == '''nt'''

__lowerCAmelCase		       =							{'''bertscore''', '''frugalscore''', '''perplexity'''}
__lowerCAmelCase		       =							importlib.util.find_spec('''transformers''') is not None




def    snake_case_     (  snake_case     )  ->				int:
       @wraps(snake_case     )
       def wrapper(self			,							snake_case     ):
              if not _has_fairseq and metric_name in REQUIRE_FAIRSEQ:
                     self.skipTest('"test requires Fairseq"'     )
              else:
                     test_case(self			,							snake_case     )

       return wrapper




def    snake_case_     (  snake_case     )  ->				str:
       @wraps(snake_case     )
       def wrapper(self			,							snake_case     ):
              if not _has_transformers and metric_name in REQUIRE_TRANSFORMERS:
                     self.skipTest('"test requires transformers"'     )
              else:
                     test_case(self			,							snake_case     )

       return wrapper




def    snake_case_     (  snake_case     )  ->				Union[str, Any]:
       @wraps(snake_case     )
       def wrapper(self			,							snake_case     ):
              if _on_windows and metric_name in UNSUPPORTED_ON_WINDOWS:
                     self.skipTest('"test not supported on Windows"'     )
              else:
                     test_case(self			,							snake_case     )

       return wrapper




def    snake_case_     (  )  ->				Any:
       lowercase__:   List[Any]  			=   [metric_dir.split(os.sep     )[-2] for metric_dir in glob.glob('./metrics/*/'     )]
       return [{"testcase_name": x, "metric_name": x} for x in metrics if x != "gleu"]  # gleu is unfinished





@parameterized.named_parameters(get_local_metric_names()      )
@for_all_test_methods(
    __UpperCamelCase       ,       __UpperCamelCase       ,       __UpperCamelCase      )
@local
class   __a			(    parameterized.TestCase      ):
 __lowercase :							Any        = {}
 __lowercase :							Optional[Any]        = None
 @pytest.mark.filterwarnings('ignore:metric_module_factory is deprecated:FutureWarning' )
 @pytest.mark.filterwarnings('ignore:load_metric is deprecated:FutureWarning' )
 def 		SCREAMING_SNAKE_CASE__   (   self				, lowerCAmelCase__ )					->				Union[str, Any]:




        '''simple docstring'''
        lowercase__:   Any  			=   '[...]'
        lowercase__:   Tuple  			=   importlib.import_module(
            datasets.load.metric_module_factory(os.path.join('metrics'				, lowerCAmelCase__ ) ).module_path )
        lowercase__:   Tuple  			=   datasets.load.import_main_class(metric_module.__name__				, dataset=lowerCAmelCase__ )
        # check parameters
        lowercase__:   Tuple  			=   inspect.signature(metric._compute ).parameters
        self.assertTrue(all(p.kind != p.VAR_KEYWORD for p in parameters.values() ) )  # no **kwargs
        # run doctest
        with self.patch_intensive_calls(lowerCAmelCase__				, metric_module.__name__ ):
               with self.use_local_metrics():
                      try:
                             lowercase__:   str  			=   doctest.testmod(lowerCAmelCase__				, verbose=lowerCAmelCase__				, raise_on_error=lowerCAmelCase__ )
                      except doctest.UnexpectedException as e:
                             raise e.exc_info[1]  # raise the exception that doctest caught
        self.assertEqual(results.failed				, 0 )
        self.assertGreater(results.attempted				, 1 )
 @slow
 def 		SCREAMING_SNAKE_CASE__   (   self				, lowerCAmelCase__ )					->				Optional[Any]:




        '''simple docstring'''
        lowercase__:   Union[str, Any]  			=   '[...]'
        lowercase__:   Tuple  			=   importlib.import_module(
            datasets.load.metric_module_factory(os.path.join('metrics'				, lowerCAmelCase__ ) ).module_path )
        # run doctest
        with self.use_local_metrics():
               lowercase__:   str  			=   doctest.testmod(lowerCAmelCase__				, verbose=lowerCAmelCase__				, raise_on_error=lowerCAmelCase__ )
        self.assertEqual(results.failed				, 0 )
        self.assertGreater(results.attempted				, 1 )
 @contextmanager
 def 		SCREAMING_SNAKE_CASE__   (   self				, lowerCAmelCase__				, lowerCAmelCase__ )					->				Optional[Any]:




        '''simple docstring'''
        if metric_name in self.INTENSIVE_CALLS_PATCHER:
               with self.INTENSIVE_CALLS_PATCHER[metric_name](lowerCAmelCase__ ):
                      yield
        else:
               yield
 @contextmanager
 def 		SCREAMING_SNAKE_CASE__   (   self )					->				int:




        '''simple docstring'''
        def load_local_metric(lowerCAmelCase__				, *lowerCAmelCase__				, **lowerCAmelCase__ ):
               return load_metric(os.path.join('metrics'				, lowerCAmelCase__ )				, *lowerCAmelCase__				, **lowerCAmelCase__ )

        with patch('datasets.load_metric' ) as mock_load_metric:
               lowercase__:   Any  			=   load_local_metric
               yield
 @classmethod
 def 		SCREAMING_SNAKE_CASE__   (   cls				, lowerCAmelCase__ )					->				List[Any]:




        '''simple docstring'''
        def wrapper(lowerCAmelCase__ ):
               lowercase__:   str  			=   contextmanager(lowerCAmelCase__ )
               lowercase__:   Optional[int]  			=   patcher
               return patcher

        return wrapper





@LocalMetricTest.register_intensive_calls_patcher('bleurt'     )
def    snake_case_     (  snake_case     )  ->				Any:
       import tensorflow.compat.va as tf
       from bleurt.score import Predictor

       tf.flags.DEFINE_string('sv'			,							''			,							''     )  # handle pytest cli flags





       class   __a			(    __UpperCamelCase      ):
        def 		SCREAMING_SNAKE_CASE__   (   self				, lowerCAmelCase__ )					->				Dict:




               '''simple docstring'''
               assert len(input_dict['input_ids'] ) == 2
               return np.array([1.0_3, 1.0_4] )

    # mock predict_fn which is supposed to do a forward pass with a bleurt model
       with patch('bleurt.score._create_predictor'     ) as mock_create_predictor:
              lowercase__:   Tuple  			=   MockedPredictor()
              yield




@LocalMetricTest.register_intensive_calls_patcher('bertscore'     )
def    snake_case_     (  snake_case     )  ->				Tuple:
       import torch

       def bert_cos_score_idf(snake_case			,							snake_case			,							*snake_case			,							**snake_case     ):
              return torch.tensor([[1.0, 1.0, 1.0]] * len(snake_case     )     )

       # mock get_model which is supposed to do download a bert model
       # mock bert_cos_score_idf which is supposed to do a forward pass with a bert model
       with patch('bert_score.scorer.get_model'     ), patch(
           'bert_score.scorer.bert_cos_score_idf'     ) as mock_bert_cos_score_idf:
              lowercase__:   Optional[Any]  			=   bert_cos_score_idf
              yield




@LocalMetricTest.register_intensive_calls_patcher('comet'     )
def    snake_case_     (  snake_case     )  ->				Any:
       def load_from_checkpoint(snake_case     ):





              class   __a			:
               def 		SCREAMING_SNAKE_CASE__   (   self				, lowerCAmelCase__				, *lowerCAmelCase__				, **lowerCAmelCase__ )					->				Optional[Any]:




                      '''simple docstring'''
                      assert len(lowerCAmelCase__ ) == 2
                      lowercase__:   List[Any]  			=   [0.1_9, 0.9_2]
                      return scores, sum(lowerCAmelCase__ ) / len(lowerCAmelCase__ )





              return Model()

       # mock load_from_checkpoint which is supposed to do download a bert model
       # mock load_from_checkpoint which is supposed to do download a bert model
       with patch('comet.download_model'     ) as mock_download_model:
              lowercase__:   Optional[int]  			=   None
              with patch('comet.load_from_checkpoint'     ) as mock_load_from_checkpoint:
                     lowercase__:   Dict  			=   load_from_checkpoint
                     yield




def    snake_case_     (  )  ->				int:
       lowercase__:   Dict  			=   load_metric(os.path.join('metrics'			,							'seqeval'     )     )
       lowercase__:   List[str]  			=   'ERROR'
       lowercase__:   str  			=   f'Scheme should be one of [IOB1, IOB2, IOE1, IOE2, IOBES, BILOU], got {wrong_scheme}'
       with pytest.raises(snake_case			,							match=re.escape(snake_case     )     ):
              metric.compute(predictions=[]			,							references=[]			,							scheme=snake_case     )






def    snake_case_     (  snake_case     )  ->				int:
       if n == 1 or not isinstance(snake_case			,							snake_case     ):
              return 0
       elif n == 2:
              return 1
       else:
              lowercase__:   Optional[Any]  			=   [0, 1]
              for i in range(2			,							n + 1     ):
                     sequence.append(sequence[i - 1] + sequence[i - 2]     )

              return sequence[n]




def    snake_case_     (  snake_case     )  ->				int:
       lowercase__:   int  			=   0
       lowercase__:   int  			=   2

       while digits < n:
              index += 1
              lowercase__:   Tuple  			=   len(str(fibonacci(snake_case     )     )     )

       return index




def    snake_case_     (  snake_case = 10_00     )  ->				int:
       return fibonacci_digits_index(snake_case     )


if __name__ == "__main__":
 print(solution(int(str(input()).strip())))


