


'''simple docstring'''


import math
import time

from transformers import Trainer, is_torch_tpu_available
from transformers.trainer_utils import PredictionOutput, speed_metrics


if is_torch_tpu_available(check_device=False):
     import torch_xla.core.xla_model as xm
     import torch_xla.debug.metrics as met



class 	__lowerCAmelCase		(							__SCREAMING_SNAKE_CASE    ):


  '''simple docstring'''







  def __init__(							self :       List[Any]	,*_a :       List[Any]	,_a :       Optional[Any]=None	,_a :       int=None	,**_a :       Tuple ):

        '''simple docstring'''




        super().__init__(*_a	,**_a )
        A_						:  Tuple          =				eval_examples
        A_						:  Optional[int]          =				post_process_function






  def        _a							(							self :       Tuple	,_a :       Tuple=None	,_a :       Union[str, Any]=None	,_a :       List[Any]=None	,_a :       str = "eval" ):

        '''simple docstring'''




        A_						:  str          =				self.eval_dataset if eval_dataset is None else eval_dataset
        A_						:  Optional[Any]          =				self.get_eval_dataloader(_a )
        A_						:  Union[str, Any]          =				self.eval_examples if eval_examples is None else eval_examples

        # Temporarily disable metric computation, we will do it in the loop here.
        A_						:  List[str]          =				self.compute_metrics
        A_						:  Tuple          =				None
        A_						:  Optional[Any]          =				self.prediction_loop if self.args.use_legacy_prediction_loop else self.evaluation_loop
        A_						:  List[str]          =				time.time()
        try:
              A_						:  Dict          =				eval_loop(
                  _a	,description="""Evaluation"""	,prediction_loss_only=True if compute_metrics is None else None	,ignore_keys=_a	,metric_key_prefix=_a	,)
        finally:
              A_						:  Optional[Any]          =				compute_metrics
        A_						:  Tuple          =				self.args.eval_batch_size * self.args.world_size
        if f'{metric_key_prefix}_jit_compilation_time' in output.metrics:
              start_time += output.metrics[f'{metric_key_prefix}_jit_compilation_time']
        output.metrics.update(
            speed_metrics(
                _a	,_a	,num_samples=output.num_samples	,num_steps=math.ceil(output.num_samples / total_batch_size )	,) )
        if self.post_process_function is not None and self.compute_metrics is not None and self.args.should_save:
              # Only the main node write the results by default
              A_						:  int          =				self.post_process_function(_a	,_a	,output.predictions )
              A_						:  str          =				self.compute_metrics(_a )

              # Prefix all keys with metric_key_prefix + '_'
              for key in list(metrics.keys() ):
                    if not key.startswith(f'{metric_key_prefix}_' ):
                          A_						:  List[Any]          =				metrics.pop(_a )
              metrics.update(output.metrics )
        else:
              A_						:  List[Any]          =				output.metrics

        if self.args.should_log:
              # Only the main node log the results by default
              self.log(_a )

        if self.args.tpu_metrics_debug or self.args.debug:
              # tpu-comment: Logging debug metrics for PyTorch/XLA (compile, execute times, ops, etc.)
              xm.master_print(met.metrics_report() )

        A_						:  List[Any]          =				self.callback_handler.on_evaluate(self.args	,self.state	,self.control	,_a )
        return metrics






  def        _a							(							self :       Optional[Any]	,_a :       Dict	,_a :       List[Any]	,_a :       List[Any]=None	,_a :       str = "test" ):

        '''simple docstring'''




        A_						:  str          =				self.get_test_dataloader(_a )

        # Temporarily disable metric computation, we will do it in the loop here.
        A_						:  Any          =				self.compute_metrics
        A_						:  List[Any]          =				None
        A_						:  int          =				self.prediction_loop if self.args.use_legacy_prediction_loop else self.evaluation_loop
        A_						:  int          =				time.time()
        try:
              A_						:  str          =				eval_loop(
                  _a	,description="""Prediction"""	,prediction_loss_only=True if compute_metrics is None else None	,ignore_keys=_a	,metric_key_prefix=_a	,)
        finally:
              A_						:  Tuple          =				compute_metrics
        A_						:  Optional[Any]          =				self.args.eval_batch_size * self.args.world_size
        if f'{metric_key_prefix}_jit_compilation_time' in output.metrics:
              start_time += output.metrics[f'{metric_key_prefix}_jit_compilation_time']
        output.metrics.update(
            speed_metrics(
                _a	,_a	,num_samples=output.num_samples	,num_steps=math.ceil(output.num_samples / total_batch_size )	,) )

        if self.post_process_function is None or self.compute_metrics is None:
              return output

        A_						:  Any          =				self.post_process_function(_a	,_a	,output.predictions	,"""predict""" )
        A_						:  Union[str, Any]          =				self.compute_metrics(_a )

        # Prefix all keys with metric_key_prefix + '_'
        for key in list(metrics.keys() ):
              if not key.startswith(f'{metric_key_prefix}_' ):
                    A_						:  str          =				metrics.pop(_a )
        metrics.update(output.metrics )
        return PredictionOutput(predictions=predictions.predictions	,label_ids=predictions.label_ids	,metrics=_a )




'''simple docstring'''


import sys
import webbrowser

import requests
from bsa import BeautifulSoup
from fake_useragent import UserAgent

if __name__ == "__main__":
     print('Googling.....')
     __magic_name__			=      'https://www.google.com/search?q=' + ' '.join(sys.argv[1:])
     __magic_name__			=      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)
     __magic_name__			=      BeautifulSoup(res.text, 'html.parser')
     __magic_name__			=      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')}""")
