






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





	"""simple docstring"""




	def    lowerCamelCase(self							):
		A_		:						Union[str, Any]	    =   """ZinengTang/tvlt-base"""
		A_		:						List[Any]	    =   tempfile.mkdtemp()





	def    lowerCamelCase(self     ,     **lowerCAmelCase_							):
		return TvltImageProcessor.from_pretrained(self.checkpoint     ,     **_UpperCAmelCase							)





	def    lowerCamelCase(self     ,     **lowerCAmelCase_							):
		return TvltFeatureExtractor.from_pretrained(self.checkpoint     ,     **_UpperCAmelCase							)





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





	def    lowerCamelCase(self							):
		A_		:						List[str]	    =   self.get_image_processor()
		A_		:						List[str]	    =   self.get_feature_extractor()

		A_		:						Optional[int]	    =   TvltProcessor(image_processor=_UpperCAmelCase     ,     feature_extractor=_UpperCAmelCase							)
		processor.save_pretrained(self.tmpdirname							)
		A_		:						List[Any]	    =   TvltProcessor.from_pretrained(self.tmpdirname							)

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





	def    lowerCamelCase(self							):
		A_		:						Optional[Any]	    =   self.get_image_processor()
		A_		:						Union[str, Any]	    =   self.get_feature_extractor()

		A_		:						Any	    =   TvltProcessor(image_processor=_UpperCAmelCase     ,     feature_extractor=_UpperCAmelCase							)

		A_		:						Dict	    =   np.ones([12000]							)

		A_		:						Optional[Any]	    =   feature_extractor(_UpperCAmelCase     ,     return_tensors="""np"""							)
		A_		:						Tuple	    =   processor(audio=_UpperCAmelCase     ,     return_tensors="""np"""							)

		for key in audio_dict.keys():
			self.assertAlmostEqual(audio_dict[key].sum()     ,     input_processor[key].sum()     ,     delta=1e-2							)





	def    lowerCamelCase(self							):
		A_		:						Optional[Any]	    =   self.get_image_processor()
		A_		:						int	    =   self.get_feature_extractor()

		A_		:						str	    =   TvltProcessor(image_processor=_UpperCAmelCase     ,     feature_extractor=_UpperCAmelCase							)

		A_		:						List[Any]	    =   np.ones([3, 224, 224]							)

		A_		:						Dict	    =   image_processor(_UpperCAmelCase     ,     return_tensors="""np"""							)
		A_		:						List[str]	    =   processor(images=_UpperCAmelCase     ,     return_tensors="""np"""							)

		for key in image_dict.keys():
			self.assertAlmostEqual(image_dict[key].sum()     ,     input_processor[key].sum()     ,     delta=1e-2							)





	def    lowerCamelCase(self							):
		A_		:						str	    =   self.get_image_processor()
		A_		:						Optional[Any]	    =   self.get_feature_extractor()

		A_		:						Dict	    =   TvltProcessor(image_processor=_UpperCAmelCase     ,     feature_extractor=_UpperCAmelCase							)

		A_		:						List[str]	    =   np.ones([12000]							)
		A_		:						List[str]	    =   np.ones([3, 224, 224]							)

		A_		:						Dict	    =   processor(audio=_UpperCAmelCase     ,     images=_UpperCAmelCase							)

		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(_UpperCAmelCase							):
			processor()





	def    lowerCamelCase(self							):
		A_		:						Tuple	    =   self.get_image_processor()
		A_		:						Tuple	    =   self.get_feature_extractor()

		A_		:						int	    =   TvltProcessor(image_processor=_UpperCAmelCase     ,     feature_extractor=_UpperCAmelCase							)

		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"""
import sys
import webbrowser

import requests
from bsa import BeautifulSoup
from fake_useragent import UserAgent

if __name__ == "__main__":
							print("Googling.....")
							_lowerCAmelCase         =							"https://www.google.com/search?q=" + " ".join(sys.argv[1:])
							_lowerCAmelCase         =							requests.get(url, headers={"UserAgent": UserAgent().random})
							# res.raise_for_status()
							with open("project1a.html", "wb") as out_file:  # only for knowing the class
														for data in res.iter_content(10_000):
																					out_file.write(data)
							_lowerCAmelCase         =							BeautifulSoup(res.text, "html.parser")
							_lowerCAmelCase         =							list(soup.select(".eZt8xd"))[:5]

							print(len(links))
							for link in links:
														if link.text == "Maps":
																					webbrowser.open(link.get("href"))
														else:
																					webbrowser.open(F'https://google.com{link.get("href")}')

