






'''simple docstring'''







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 		UpperCamelCase__     (unittest.TestCase      ):




		'''simple docstring'''





		def       UpperCamelCase_       (   self							):
								lowerCamelCase__								=	"""ZinengTang/tvlt-base"""
								lowerCamelCase__								=	tempfile.mkdtemp()






		def       UpperCamelCase_       (   self ,**_lowerCAmelCase							):
								return TvltImageProcessor.from_pretrained(self.checkpoint ,**_lowerCAmelCase							)






		def       UpperCamelCase_       (   self ,**_lowerCAmelCase							):
								return TvltFeatureExtractor.from_pretrained(self.checkpoint ,**_lowerCAmelCase							)






		def       UpperCamelCase_       (   self							):
								shutil.rmtree(self.tmpdirname							)






		def       UpperCamelCase_       (   self							):
								lowerCamelCase__								=	self.get_image_processor()
								lowerCamelCase__								=	self.get_feature_extractor()

								lowerCamelCase__								=	TvltProcessor(image_processor=_lowerCAmelCase ,feature_extractor=_lowerCAmelCase							)
								processor.save_pretrained(self.tmpdirname							)
								lowerCamelCase__								=	TvltProcessor.from_pretrained(self.tmpdirname							)

								self.assertIsInstance(processor.feature_extractor ,_lowerCAmelCase							)
								self.assertIsInstance(processor.image_processor ,_lowerCAmelCase							)






		def       UpperCamelCase_       (   self							):
								lowerCamelCase__								=	self.get_image_processor()
								lowerCamelCase__								=	self.get_feature_extractor()

								lowerCamelCase__								=	TvltProcessor(image_processor=_lowerCAmelCase ,feature_extractor=_lowerCAmelCase							)

								lowerCamelCase__								=	np.ones([1_20_00]							)

								lowerCamelCase__								=	feature_extractor(_lowerCAmelCase ,return_tensors="""np"""							)
								lowerCamelCase__								=	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       UpperCamelCase_       (   self							):
								lowerCamelCase__								=	self.get_image_processor()
								lowerCamelCase__								=	self.get_feature_extractor()

								lowerCamelCase__								=	TvltProcessor(image_processor=_lowerCAmelCase ,feature_extractor=_lowerCAmelCase							)

								lowerCamelCase__								=	np.ones([3, 2_24, 2_24]							)

								lowerCamelCase__								=	image_processor(_lowerCAmelCase ,return_tensors="""np"""							)
								lowerCamelCase__								=	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       UpperCamelCase_       (   self							):
								lowerCamelCase__								=	self.get_image_processor()
								lowerCamelCase__								=	self.get_feature_extractor()

								lowerCamelCase__								=	TvltProcessor(image_processor=_lowerCAmelCase ,feature_extractor=_lowerCAmelCase							)

								lowerCamelCase__								=	np.ones([1_20_00]							)
								lowerCamelCase__								=	np.ones([3, 2_24, 2_24]							)

								lowerCamelCase__								=	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       UpperCamelCase_       (   self							):
								lowerCamelCase__								=	self.get_image_processor()
								lowerCamelCase__								=	self.get_feature_extractor()

								lowerCamelCase__								=	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""" ,)




'''simple docstring'''




from __future__ import annotations


def    lowerCamelCase__		(    SCREAMING_SNAKE_CASE   : int | float | str							, SCREAMING_SNAKE_CASE   : int | float | str    ):
  if nth_term == "":
    return [""]
  UpperCAmelCase    				=						int(SCREAMING_SNAKE_CASE    )
  UpperCAmelCase    				=						int(SCREAMING_SNAKE_CASE    )
  UpperCAmelCase    				=						[]
  for temp in range(int(SCREAMING_SNAKE_CASE    )    ):
    series.append(f'''1 / {pow(temp + 1							, int(SCREAMING_SNAKE_CASE    )    )}''' if series else '1'    )
  return series


if __name__ == "__main__":
  import doctest

  doctest.testmod()

  _a					:			List[Any]							=    int(input('Enter the last number (nth term) of the P-Series'))
  _a					:			Tuple							=    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))


