'''simple docstring'''






import argparse
import datetime





def  _SCREAMING_SNAKE_CASE		(      __snake_case							:			str				):
     _A    		=  {
         '0': 'Sunday',
         '1': 'Monday',
         '2': 'Tuesday',
         '3': 'Wednesday',
         '4': 'Thursday',
         '5': 'Friday',
         '6': 'Saturday',
     }

     _A    		=  {0: 1, 1: 2, 2: 3, 3: 4, 4: 5, 5: 6, 6: 0}

     # Validate
     if not 0 < len(__snake_case				) < 1_1:
          raise ValueError('Must be 10 characters long'				)

     # Get month
     _A    		=  int(date_input[0] + date_input[1]				)
     # Validate
     if not 0 < m < 1_3:
          raise ValueError('Month must be between 1 - 12'				)

     _A    		=  date_input[2]
     # Validate
     if sep_a not in ["-", "/"]:
          raise ValueError('Date separator must be \'-\' or \'/\''				)

     # Get day
     _A    		=  int(date_input[3] + date_input[4]				)
     # Validate
     if not 0 < d < 3_2:
          raise ValueError('Date must be between 1 - 31'				)

     # Get second separator
     _A    		=  date_input[5]
     # Validate
     if sep_a not in ["-", "/"]:
          raise ValueError('Date separator must be \'-\' or \'/\''				)

     # Get year
     _A    		=  int(date_input[6] + date_input[7] + date_input[8] + date_input[9]				)
     # Arbitrary year range
     if not 4_5 < y < 8_5_0_0:
          raise ValueError(
              'Year out of range. There has to be some sort of limit...right?'				)

     # Get datetime obj for validation
     _A    		=  datetime.date(int(__snake_case				)   ,		int(__snake_case				)   ,		int(__snake_case				)				)

     # Start math
     if m <= 2:
          _A    		=  y - 1
          _A    		=  m + 1_2
     # maths var
     _A    		=  int(str(__snake_case				)[:2]				)
     _A    		=  int(str(__snake_case				)[2:]				)
     _A    		=  int(2.6 * m - 5.39				)
     _A    		=  int(c / 4				)
     _A    		=  int(k / 4				)
     _A    		=  int(d + k				)
     _A    		=  int(t + u + v + x				)
     _A    		=  int(z - (2 * c)				)
     _A    		=  round(w % 7				)
     # End math

     # Validate math
     if f != convert_datetime_days[dt_ck.weekday()]:
          raise AssertionError('The date was evaluated incorrectly. Contact developer.'				)

     # Response
     _A    		=  F'Your date {date_input}, is a {days[str(__snake_case				)]}!'
     return response


if __name__ == "__main__":
   import doctest

   doctest.testmod()
   _UpperCAmelCase    :     Dict         =       argparse.ArgumentParser(
       description=(
           '''Find out what day of the week nearly any date is or was. Enter '''
           '''date as a string in the mm-dd-yyyy or mm/dd/yyyy format'''
       )
   )
   parser.add_argument(
       '''date_input''', type=str, help='''Date as a string (mm-dd-yyyy or mm/dd/yyyy)'''
   )
   _UpperCAmelCase    :     Any         =       parser.parse_args()
   zeller(args.date_input)




'''simple docstring'''






import logging
import random

import ray

from transformers import RagConfig, RagRetriever, RagTokenizer
from transformers.models.rag.retrieval_rag import CustomHFIndex


_UpperCAmelCase    :     int         =       logging.getLogger(__name__)







class lowercase_       :







   """simple docstring"""

   def __init__(      self      :			Tuple     )  ->			int:
        _A    		=  False
   def 	__UpperCAmelCase   (      self      :			Optional[int], UpperCamelCase__      :			str, UpperCamelCase__      :			Optional[Any], UpperCamelCase__      :			int, UpperCamelCase__      :			Optional[Any]     )  ->			Any:
        if not self.initialized:
             _A    		=  RagRetriever(
                 UpperCamelCase__, question_encoder_tokenizer=UpperCamelCase__, generator_tokenizer=UpperCamelCase__, index=UpperCamelCase__, init_retrieval=UpperCamelCase__, )
             _A    		=  True
   def 	__UpperCAmelCase   (      self      :			Any     )  ->			List[Any]:
        self.retriever.index.init_index()

   def 	__UpperCAmelCase   (      self      :			int, UpperCamelCase__      :			Optional[Any], UpperCamelCase__      :			Dict     )  ->			Optional[Any]:
        _A		,       _A    		=  self.retriever._main_retrieve(UpperCamelCase__, UpperCamelCase__     )
        return doc_ids, retrieved_doc_embeds







class lowercase_       (		_UpperCamelCase			):







   """simple docstring"""

   def __init__(      self      :			Optional[Any], UpperCamelCase__      :			Optional[Any], UpperCamelCase__      :			Optional[int], UpperCamelCase__      :			Dict, UpperCamelCase__      :			Union[str, Any], UpperCamelCase__      :			int=None     )  ->			Optional[int]:
        if index is not None and index.is_initialized() and len(UpperCamelCase__     ) > 0:
             raise ValueError(
                 'When using Ray for distributed fine-tuning, '
                 'you\'ll need to provide the paths instead, '
                 'as the dataset and the index are loaded '
                 'separately. More info in examples/rag/use_own_knowledge_dataset.py '     )
        super().__init__(
            UpperCamelCase__, question_encoder_tokenizer=UpperCamelCase__, generator_tokenizer=UpperCamelCase__, index=UpperCamelCase__, init_retrieval=UpperCamelCase__, )
        _A    		=  retrieval_workers
        if len(self.retrieval_workers     ) > 0:
             ray.get(
                 [
                     worker.create_rag_retriever.remote(UpperCamelCase__, UpperCamelCase__, UpperCamelCase__, UpperCamelCase__     )
                     for worker in self.retrieval_workers
                 ]     )
   def 	__UpperCAmelCase   (      self      :			Dict     )  ->			int:
        logger.info('initializing retrieval'     )

        if len(self.retrieval_workers     ) > 0:
             ray.get([worker.init_retrieval.remote() for worker in self.retrieval_workers]     )
        else:
             # Non-distributed training. Load index into this same process.
             self.index.init_index()
   def 	__UpperCAmelCase   (      self      :			Optional[Any], UpperCamelCase__      :			Dict, UpperCamelCase__      :			Tuple     )  ->			Dict:
        if len(self.retrieval_workers     ) > 0:
             # Select a random retrieval actor.
             _A    		=  self.retrieval_workers[random.randint(0, len(self.retrieval_workers     ) - 1     )]
             _A		,       _A    		=  ray.get(random_worker.retrieve.remote(UpperCamelCase__, UpperCamelCase__     )     )
        else:
             _A		,       _A    		=  self._main_retrieve(UpperCamelCase__, UpperCamelCase__     )
        return retrieved_doc_embeds, doc_ids, self.index.get_doc_dicts(UpperCamelCase__     )
   @classmethod
   def 	__UpperCAmelCase   (      cls      :			List[str], UpperCamelCase__      :			List[Any], UpperCamelCase__      :			List[Any]=None, **UpperCamelCase__      :			Optional[int]     )  ->			Optional[Any]:
        return super(UpperCamelCase__, cls     ).get_tokenizers(UpperCamelCase__, UpperCamelCase__, **UpperCamelCase__     )

   @classmethod
   def 	__UpperCAmelCase   (      cls      :			Any, UpperCamelCase__      :			Tuple, UpperCamelCase__      :			int, UpperCamelCase__      :			List[Any]=None, **UpperCamelCase__      :			List[str]     )  ->			Tuple:
        _A    		=  kwargs.pop('config', UpperCamelCase__     ) or RagConfig.from_pretrained(UpperCamelCase__, **UpperCamelCase__     )
        _A    		=  RagTokenizer.from_pretrained(UpperCamelCase__, config=UpperCamelCase__     )
        _A    		=  rag_tokenizer.question_encoder
        _A    		=  rag_tokenizer.generator
        if indexed_dataset is not None:
             _A    		=  'custom'
             _A    		=  CustomHFIndex(config.retrieval_vector_size, UpperCamelCase__     )
        else:
             _A    		=  cls._build_index(UpperCamelCase__     )
        return cls(
            UpperCamelCase__, question_encoder_tokenizer=UpperCamelCase__, generator_tokenizer=UpperCamelCase__, retrieval_workers=UpperCamelCase__, index=UpperCamelCase__, )



