


import shutil
import tempfile
import unittest

import numpy as np
import pytest

from transformers import is_speech_available, is_vision_available
from transformers.testing_utils import require_torch


if is_vision_available():
 from transformers import TvltImageProcessor

if is_speech_available():
 from transformers import TvltFeatureExtractor

from transformers import TvltProcessor





@require_torch
class   __a      (   unittest.TestCase				):
 def 		SCREAMING_SNAKE_CASE__       (       self			) ->    Any:




        '''simple docstring'''
        lowercase__:       int        =       'ZinengTang/tvlt-base'
        lowercase__:       Any        =       tempfile.mkdtemp()
 def 		SCREAMING_SNAKE_CASE__       (       self    ,			**lowerCAmelCase__			) ->    Union[str, Any]:




        '''simple docstring'''
        return TvltImageProcessor.from_pretrained(self.checkpoint    ,			**lowerCAmelCase__			)
 def 		SCREAMING_SNAKE_CASE__       (       self    ,			**lowerCAmelCase__			) ->    Dict:




        '''simple docstring'''
        return TvltFeatureExtractor.from_pretrained(self.checkpoint    ,			**lowerCAmelCase__			)
 def 		SCREAMING_SNAKE_CASE__       (       self			) ->    List[Any]:




        '''simple docstring'''
        shutil.rmtree(self.tmpdirname			)
 def 		SCREAMING_SNAKE_CASE__       (       self			) ->    str:




        '''simple docstring'''
        lowercase__:       Optional[int]        =       self.get_image_processor()
        lowercase__:       Union[str, Any]        =       self.get_feature_extractor()

        lowercase__:       List[Any]        =       TvltProcessor(image_processor=lowerCAmelCase__    ,			feature_extractor=lowerCAmelCase__			)
        processor.save_pretrained(self.tmpdirname			)
        lowercase__:       Tuple        =       TvltProcessor.from_pretrained(self.tmpdirname			)

        self.assertIsInstance(processor.feature_extractor    ,			lowerCAmelCase__			)
        self.assertIsInstance(processor.image_processor    ,			lowerCAmelCase__			)
 def 		SCREAMING_SNAKE_CASE__       (       self			) ->    str:




        '''simple docstring'''
        lowercase__:       Optional[Any]        =       self.get_image_processor()
        lowercase__:       Optional[Any]        =       self.get_feature_extractor()

        lowercase__:       Optional[Any]        =       TvltProcessor(image_processor=lowerCAmelCase__    ,			feature_extractor=lowerCAmelCase__			)

        lowercase__:       Tuple        =       np.ones([12_000]			)

        lowercase__:       List[Any]        =       feature_extractor(lowerCAmelCase__    ,			return_tensors='np'			)
        lowercase__:       List[str]        =       processor(audio=lowerCAmelCase__    ,			return_tensors='np'			)

        for key in audio_dict.keys():
               self.assertAlmostEqual(audio_dict[key].sum()    ,			input_processor[key].sum()    ,			delta=1E-2			)
 def 		SCREAMING_SNAKE_CASE__       (       self			) ->    Optional[Any]:




        '''simple docstring'''
        lowercase__:       int        =       self.get_image_processor()
        lowercase__:       Union[str, Any]        =       self.get_feature_extractor()

        lowercase__:       Any        =       TvltProcessor(image_processor=lowerCAmelCase__    ,			feature_extractor=lowerCAmelCase__			)

        lowercase__:       Optional[int]        =       np.ones([3, 224, 224]			)

        lowercase__:       Optional[int]        =       image_processor(lowerCAmelCase__    ,			return_tensors='np'			)
        lowercase__:       int        =       processor(images=lowerCAmelCase__    ,			return_tensors='np'			)

        for key in image_dict.keys():
               self.assertAlmostEqual(image_dict[key].sum()    ,			input_processor[key].sum()    ,			delta=1E-2			)
 def 		SCREAMING_SNAKE_CASE__       (       self			) ->    int:




        '''simple docstring'''
        lowercase__:       Any        =       self.get_image_processor()
        lowercase__:       Optional[Any]        =       self.get_feature_extractor()

        lowercase__:       List[str]        =       TvltProcessor(image_processor=lowerCAmelCase__    ,			feature_extractor=lowerCAmelCase__			)

        lowercase__:       Any        =       np.ones([12_000]			)
        lowercase__:       Any        =       np.ones([3, 224, 224]			)

        lowercase__:       Optional[Any]        =       processor(audio=lowerCAmelCase__    ,			images=lowerCAmelCase__			)

        self.assertListEqual(list(inputs.keys()			)    ,			['audio_values', 'audio_mask', 'pixel_values', 'pixel_mask']			)

        # test if it raises when no input is passed
        with pytest.raises(lowerCAmelCase__			):
               processor()
 def 		SCREAMING_SNAKE_CASE__       (       self			) ->    Any:




        '''simple docstring'''
        lowercase__:       Tuple        =       self.get_image_processor()
        lowercase__:       Optional[int]        =       self.get_feature_extractor()

        lowercase__:       Any        =       TvltProcessor(image_processor=lowerCAmelCase__    ,			feature_extractor=lowerCAmelCase__			)

        self.assertListEqual(
            processor.model_input_names    ,			image_processor.model_input_names + feature_extractor.model_input_names    ,			msg='`processor` and `image_processor`+`feature_extractor` model input names do not match'    ,			)






from __future__ import annotations




def        snake_case_					(  snake_case      ,							snake_case					)  ->    list[str]:
       if nth_term == "":
              return [""]
       lowercase__:       Tuple        =       int(snake_case					)
       lowercase__:       int        =       int(snake_case					)
       lowercase__:       list[str]        =       []
       for temp in range(int(snake_case					)					):
              series.append(f'1 / {pow(temp + 1      ,							int(snake_case					)					)}' if series else '1'					)
       return series


if __name__ == "__main__":
 import doctest

 doctest.testmod()

 __lowerCAmelCase			=							int(input('''Enter the last number (nth term) of the P-Series'''))
 __lowerCAmelCase			=							int(input('''Enter the power for  P-Series'''))
 print('''Formula of P-Series => 1+1/2^p+1/3^p ..... 1/n^p''')
 print(p_series(nth_term, power))


