
import importlib.metadata
import subprocess
import sys




def 				__magic_name__				(     __lowerCAmelCase			:		bool = False							)    ->     Tuple:
				__lowerCamelCase					      =			False
				if "IPython" in sys.modules:
								__lowerCamelCase					      =			'''google.colab''' in str(sys.modules['''IPython'''].get_ipython()							)

				if in_colab:
								if upgrade:
												__lowerCamelCase					      =			['''pip''', '''install''', '''-U''', '''torch''']
												subprocess.run(__lowerCAmelCase	,						check=__lowerCAmelCase							)
								# get the current version of torch
								__lowerCamelCase					      =			importlib.metadata.version('''torch'''							)
								__lowerCamelCase					      =			torch_version[: torch_version.rindex('''.'''							)]
								__lowerCamelCase					      =			f'''https://storage.googleapis.com/tpu-pytorch/wheels/colab/torch_xla-{torch_version_trunc}-cp37-cp37m-linux_x86_64.whl'''
								__lowerCamelCase					      =			['''pip''', '''install''', xla_wheel]
								subprocess.run(__lowerCAmelCase	,						check=__lowerCAmelCase							)
				else:
								raise RuntimeError('''`install_xla` utility works only on google colab.'''							)





import bsa
import requests




def 				__magic_name__				(     __lowerCAmelCase			:		bsa.element.ResultSet							)    ->     dict[str, str]:
				return {
				    "name": soup.ha.a.text,
				    "genre": soup.find('''span'''	,						class_='''genre'''							).text.strip(),
				    "rating": soup.strong.text,
				    "page_link": f'''https://www.imdb.com{soup.a.get('href'							)}''',
				}




def 				__magic_name__				(     __lowerCAmelCase			:		int = 5							)    ->     tuple:
				__lowerCamelCase					      =			int(float(__lowerCAmelCase							)							)
				if num_movies < 1:
								return ()
				__lowerCamelCase					      =			(
				    '''https://www.imdb.com/search/title?title_type='''
				    f'''feature&sort=num_votes,desc&count={num_movies}'''
				)
				__lowerCamelCase					      =			bsa.BeautifulSoup(requests.get(__lowerCAmelCase							).content	,						'''html.parser'''							)
				return tuple(
				    get_movie_data_from_soup(__lowerCAmelCase							)
				    for movie in source.find_all('''div'''	,						class_='''lister-item mode-advanced'''							)							)


if __name__ == "__main__":
					import json

					SCREAMING_SNAKE_CASE__     :    str      							=					int(input("How many movies would you like to see? "))
					print(
					    ", ".join(
					        json.dumps(movie, indent=4) for movie in get_imdb_top_movies(num_movies)
					    )
					)



