




import importlib
import sys
from argparse import REMAINDER, ArgumentParser
from pathlib import Path

import torch_xla.distributed.xla_multiprocessing as xmp
def 		a_							( ):
  lowerCAmelCase__										=      ArgumentParser(
      description=(
          '''PyTorch TPU distributed training launch '''
          '''helper utility that will spawn up '''
          '''multiple distributed processes'''
      )				)

  # Optional arguments for the launch helper
  parser.add_argument('''--num_cores'''   , type=__lowerCAmelCase   , default=1   , help='''Number of TPU cores to use (1 or 8).'''				)

  # positional
  parser.add_argument(
      '''training_script'''   , type=__lowerCAmelCase   , help=(
          '''The full path to the single TPU training '''
          '''program/script to be launched in parallel, '''
          '''followed by all the arguments for the '''
          '''training script'''
      )   , )

  # rest from the training program
  parser.add_argument('''training_script_args'''   , nargs=__lowerCAmelCase				)

  return parser.parse_args()
def 		a_							( ):
  lowerCAmelCase__										=      parse_args()

  # Import training_script as a module.
  lowerCAmelCase__										=      Path(args.training_script				)
  sys.path.append(str(script_fpath.parent.resolve()				)				)
  lowerCAmelCase__										=      script_fpath.stem
  lowerCAmelCase__										=      importlib.import_module(__lowerCAmelCase				)

  # Patch sys.argv
  lowerCAmelCase__										=      [args.training_script] + args.training_script_args + ['''--tpu_num_cores''', str(args.num_cores				)]
  xmp.spawn(mod._mp_fn   , args=()   , nprocs=args.num_cores				)


if __name__ == "__main__":
      main()







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__":
      __magic_name__  :  List[Any]					=       """%20""".join(argv[1:]) if len(argv) > 1 else quote(str(input("""Search: """)))

      print("""Googling.....""")

      __magic_name__  :  List[Any]					=       F"https://www.google.com/search?q={query}&num=100"

      __magic_name__  :  Union[str, Any]					=       requests.get(
          url,
          headers={"""User-Agent""": str(UserAgent().random)},
      )

      try:
            __magic_name__  :  Optional[Any]					=       (
                BeautifulSoup(res.text, """html.parser""")
                .find("""div""", attrs={"""class""": """yuRUbf"""})
                .find("""a""")
                .get("""href""")
            )

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

      webbrowser.open(link)

