


import webbrowser
from sys import argv
from urllib.parse import parse_qs, quote

import requests
from bsa import BeautifulSoup
from fake_useragent import UserAgent

if __name__ == "__main__":
	SCREAMING_SNAKE_CASE			:			Any        =     "%20".join(argv[1:]) if len(argv) > 1 else quote(str(input("Search: ")))

	print("Googling.....")

	SCREAMING_SNAKE_CASE			:			Union[str, Any]        =     F"""https://www.google.com/search?q={query}&num=100"""

	SCREAMING_SNAKE_CASE			:			Tuple        =     requests.get(
	    url,
	    headers={"User-Agent": str(UserAgent().random)},
	)

	try:
		SCREAMING_SNAKE_CASE			:			Tuple        =     (
		    BeautifulSoup(res.text, "html.parser")
		    .find("div", attrs={"class": "yuRUbf"})
		    .find("a")
		    .get("href")
		)

	except AttributeError:
		SCREAMING_SNAKE_CASE			:			Dict        =     parse_qs(
		    BeautifulSoup(res.text, "html.parser")
		    .find("div", attrs={"class": "kCrYT"})
		    .find("a")
		    .get("href")
		)["url"][0]

	webbrowser.open(link)






'''simple docstring'''
import inspect
import os
import unittest

import torch

import accelerate
from accelerate import debug_launcher
from accelerate.test_utils import (
    execute_subprocess_async,
    require_cpu,
    require_huggingface_suite,
    require_multi_gpu,
    require_single_gpu,
)
from accelerate.utils import patch_environment
@require_huggingface_suite
class   lowercase      (				unittest.TestCase   ):

		"""simple docstring"""

		def        lowerCAmelCase__							(						self				):

							'''simple docstring'''


							UpperCamelCase__  :Any				   =					inspect.getfile(accelerate.test_utils				)
							UpperCamelCase__  :Any				   =					os.path.sep.join(
							    mod_file.split(os.path.sep				)[:-1] + ['''scripts''', '''external_deps''', '''test_metrics.py''']				)

							from accelerate.test_utils.scripts.external_deps import test_metrics  # noqa: F401

							UpperCamelCase__  :List[str]				   =					test_metrics




		@require_cpu
		def        lowerCAmelCase__							(						self				):

							'''simple docstring'''


							debug_launcher(self.test_metrics.main       ,  num_processes=1				)




		@require_cpu
		def        lowerCAmelCase__							(						self				):

							'''simple docstring'''


							debug_launcher(self.test_metrics.main				)




		@require_single_gpu
		def        lowerCAmelCase__							(						self				):

							'''simple docstring'''


							self.test_metrics.main()




		@require_multi_gpu
		def        lowerCAmelCase__							(						self				):

							'''simple docstring'''


							print(F'''Found {torch.cuda.device_count()} devices.'''				)
							UpperCamelCase__  :Optional[Any]				   =					['''torchrun''', F'''--nproc_per_node={torch.cuda.device_count()}''', self.test_file_path]
							with patch_environment(omp_num_threads=1				):
												execute_subprocess_async(UpperCamelCase_       ,  env=os.environ.copy()				)