




"""simple docstring"""

import datasets
import faiss
import numpy as np
import streamlit as st
import torch
from elasticsearch import Elasticsearch
from elia_utils import (
    embed_questions_for_retrieval,
    make_qa_sas_model,
    qa_sas_generate,
    query_es_index,
    query_qa_dense_index,
)

import transformers
from transformers import AutoModel, AutoModelForSeqaSeqLM, AutoTokenizer


a							      =     '''bart'''
a							      =     True






@st.cache(allow_output_mutation=_snake_case				)
def 		_snake_case	(   )       ->   str:






      '''simple docstring'''


      if LOAD_DENSE_INDEX:
            _A     =  AutoTokenizer.from_pretrained('yjernite/retribert-base-uncased'				)
            _A     =  AutoModel.from_pretrained('yjernite/retribert-base-uncased'				).to('cuda:0'				)
            _A     =  qar_model.eval()
      else:
            _A  ,       _A     =  (None, None)
      if MODEL_TYPE == "bart":
            _A     =  AutoTokenizer.from_pretrained('yjernite/bart_eli5'				)
            _A     =  AutoModelForSeqaSeqLM.from_pretrained('yjernite/bart_eli5'				).to('cuda:0'				)
            _A     =  torch.load('seq2seq_models/eli5_bart_model_blm_2.pth'				)
            sas_model.load_state_dict(save_dict['model']				)
            _A     =  sas_model.eval()
      else:
            _A  ,       _A     =  make_qa_sas_model(
                model_name='t5-small'							,    from_file='seq2seq_models/eli5_t5_model_1024_4.pth'							,    device='cuda:0'				)
      return (qar_tokenizer, qar_model, sas_tokenizer, sas_model)






@st.cache(allow_output_mutation=_snake_case				)
def 		_snake_case	(   )       ->   List[Any]:






      '''simple docstring'''


      if LOAD_DENSE_INDEX:
            _A     =  faiss.StandardGpuResources()
            _A     =  datasets.load_dataset(path='wiki_snippets'							,    name='wiki40b_en_100_0'				)['train']
            _A     =  np.memmap(
                'wiki40b_passages_reps_32_l-8_h-768_b-512-512.dat'							,    dtype='float32'							,    mode='r'							,    shape=(wikiaab_passages.num_rows, 1_28)							,    )
            _A     =  faiss.IndexFlatIP(1_28				)
            _A     =  faiss.index_cpu_to_gpu(_snake_case							,    1							,    _snake_case				)
            wikiaab_gpu_index_flat.add(_snake_case				)  # TODO fix for larger GPU
      else:
            _A  ,       _A     =  (None, None)
      _A     =  Elasticsearch([{'host': 'localhost', 'port': '9200'}]				)
      return (wikiaab_passages, wikiaab_gpu_index_flat, es_client)






@st.cache(allow_output_mutation=_snake_case				)
def 		_snake_case	(   )       ->   Optional[int]:






      '''simple docstring'''


      _A     =  datasets.load_dataset('eli5'							,    name='LFQA_reddit'				)
      _A     =  elia['train_eli5']
      _A     =  np.memmap(
          'eli5_questions_reps.dat'							,    dtype='float32'							,    mode='r'							,    shape=(elia_train.num_rows, 1_28)				)
      _A     =  faiss.IndexFlatIP(1_28				)
      eli5_train_q_index.add(_snake_case				)
      return (elia_train, eli5_train_q_index)


a      ,		a      ,		a							      =     load_indexes()
a      ,		a      ,		a      ,		a							      =     load_models()
a      ,		a							      =     load_train_data()






def 		_snake_case	(   _snake_case				:   Dict							,    _snake_case				:   List[str]=10				)       ->   Any:






      '''simple docstring'''


      _A     =  embed_questions_for_retrieval([question]							,    _snake_case							,    _snake_case				)
      _A  ,       _A     =  eli5_train_q_index.search(_snake_case							,    _snake_case				)
      _A     =  [elia_train[int(_snake_case				)] for i in I[0]]
      return nn_examples






def 		_snake_case	(   _snake_case				:   List[Any]							,    _snake_case				:   Union[str, Any]="wiki40b"							,    _snake_case				:   Dict="dense"							,    _snake_case				:   Optional[int]=10				)       ->   Tuple:






      '''simple docstring'''


      if source == "none":
            _A  ,       _A     =  (' <P> '.join(['' for _ in range(11				)]				).strip(), [])
      else:
            if method == "dense":
                  _A  ,       _A     =  query_qa_dense_index(
                      _snake_case							,    _snake_case							,    _snake_case							,    _snake_case							,    _snake_case							,    _snake_case				)
            else:
                  _A  ,       _A     =  query_es_index(
                      _snake_case							,    _snake_case							,    index_name='english_wiki40b_snippets_100w'							,    n_results=_snake_case							,    )
      _A     =  [
          (res['article_title'], res['section_title'].strip(), res['score'], res['passage_text']) for res in hit_lst
      ]
      _A     =  'question: {} context: {}'.format(_snake_case							,    _snake_case				)
      return question_doc, support_list






@st.cache(
    hash_funcs={
        torch.Tensor: (lambda _snake_case				: None),
        transformers.models.bart.tokenization_bart.BartTokenizer: (lambda _snake_case				: None),
    }				)
def 		_snake_case	(   _snake_case				:   Union[str, Any]							,    _snake_case				:   Tuple							,    _snake_case				:   List[str]							,    _snake_case				:   int=64							,    _snake_case				:   Any=2_56							,    _snake_case				:   Tuple=False							,    _snake_case				:   List[str]=2							,    _snake_case				:   Optional[Any]=0.95							,    _snake_case				:   Optional[int]=0.8				)       ->   Dict:






      '''simple docstring'''


      with torch.no_grad():
            _A     =  qa_sas_generate(
                _snake_case							,    _snake_case							,    _snake_case							,    num_answers=1							,    num_beams=_snake_case							,    min_len=_snake_case							,    max_len=_snake_case							,    do_sample=_snake_case							,    temp=_snake_case							,    top_p=_snake_case							,    top_k=_snake_case							,    max_input_length=10_24							,    device='cuda:0'							,    )[0]
      return (answer, support_list)


st.title('''Long Form Question Answering with ELI5''')

# Start sidebar
a							      =     '''<img src=\'https://huggingface.co/front/assets/huggingface_logo.svg\'>'''
a							      =     '''
<html>
  <head>
    <style>
      .img-container {
        padding-left: 90px;
        padding-right: 90px;
        padding-top: 50px;
        padding-bottom: 50px;
        background-color: #f0f3f9;
      }
    </style>
  </head>
  <body>
    <span class="img-container"> <!-- Inline parent element -->
      %s
    </span>
  </body>
</html>
''' % (
    header_html,
)
st.sidebar.markdown(
    header_full,
    unsafe_allow_html=True,
)

# Long Form QA with ELI5 and Wikipedia
a							      =     '''
This demo presents a model trained to [provide long-form answers to open-domain questions](https://yjernite.github.io/lfqa.html).
First, a document retriever fetches a set of relevant Wikipedia passages given the question from the [Wiki40b](https://research.google/pubs/pub49029/) dataset,
a pre-processed fixed snapshot of Wikipedia.
'''
st.sidebar.markdown(description, unsafe_allow_html=True)

a							      =     [
    '''Answer the question''',
    '''View the retrieved document only''',
    '''View the most similar ELI5 question and answer''',
    '''Show me everything, please!''',
]
a							      =     st.sidebar.checkbox('''Demo options''')
if demo_options:
       a							      =     st.sidebar.selectbox(
           '''''',
           action_list,
           index=3,
       )
       a							      =     action_list.index(action_st)
       a							      =     st.sidebar.selectbox(
           '''''',
           ['''Show full text of passages''', '''Show passage section titles'''],
           index=0,
       )
       a							      =     show_type == '''Show full text of passages'''
else:
       a							      =     3
       a							      =     True

a							      =     st.sidebar.checkbox('''Retrieval options''')
if retrieval_options:
       a							      =     '''
    ### Information retriever options

    The **sparse** retriever uses ElasticSearch, while the **dense** retriever uses max-inner-product search between a question and passage embedding
    trained using the [ELI5](https://arxiv.org/abs/1907.09190) questions-answer pairs.
    The answer is then generated by sequence to sequence model which takes the question and retrieved document as input.
    '''
       st.sidebar.markdown(retriever_info)
       a							      =     st.sidebar.selectbox('''Which Wikipedia format should the model use?''', ['''wiki40b''', '''none'''])
       a							      =     st.sidebar.selectbox('''Which Wikipedia indexer should the model use?''', ['''dense''', '''sparse''', '''mixed'''])
else:
       a							      =     '''wiki40b'''
       a							      =     '''dense'''

a							      =     '''beam'''
a							      =     2
a							      =     64
a							      =     256
a							      =     None
a							      =     None
a							      =     st.sidebar.checkbox('''Generation options''')
if generate_options:
       a							      =     '''
    ### Answer generation options

    The sequence-to-sequence model was initialized with [BART](https://huggingface.co/facebook/bart-large)
    weights and fine-tuned on the ELI5 QA pairs and retrieved documents. You can use the model for greedy decoding with
    **beam** search, or **sample** from the decoder\'s output probabilities.
    '''
       st.sidebar.markdown(generate_info)
       a							      =     st.sidebar.selectbox('''Would you like to use beam search or sample an answer?''', ['''beam''', '''sampled'''])
       a							      =     st.sidebar.slider(
           '''Minimum generation length''', min_value=8, max_value=256, value=64, step=8, format=None, key=None
       )
       a							      =     st.sidebar.slider(
           '''Maximum generation length''', min_value=64, max_value=512, value=256, step=16, format=None, key=None
       )
       if sampled == "beam":
              a							      =     st.sidebar.slider('''Beam size''', min_value=1, max_value=8, value=2, step=None, format=None, key=None)
       else:
              a							      =     st.sidebar.slider(
                  '''Nucleus sampling p''', min_value=0.1, max_value=1.0, value=0.9_5, step=0.0_1, format=None, key=None
              )
              a							      =     st.sidebar.slider(
                  '''Temperature''', min_value=0.1, max_value=1.0, value=0.7, step=0.0_1, format=None, key=None
              )
              a							      =     None

# start main text
a							      =     [
    '''<MY QUESTION>''',
    '''How do people make chocolate?''',
    '''Why do we get a fever when we are sick?''',
    '''How can different animals perceive different colors?''',
    '''What is natural language processing?''',
    '''What\'s the best way to treat a sunburn?''',
    '''What exactly are vitamins ?''',
    '''How does nuclear energy provide electricity?''',
    '''What\'s the difference between viruses and bacteria?''',
    '''Why are flutes classified as woodwinds when most of them are made out of metal ?''',
    '''Why do people like drinking coffee even though it tastes so bad?''',
    '''What happens when wine ages? How does it make the wine taste better?''',
    '''If an animal is an herbivore, where does it get the protein that it needs to survive if it only eats grass?''',
    '''How can we set a date to the beginning or end of an artistic period? Doesn\'t the change happen gradually?''',
    '''How does New Zealand have so many large bird predators?''',
]
a							      =     st.selectbox(
    '''What would you like to ask? ---- select <MY QUESTION> to enter a new query''',
    questions_list,
    index=1,
)
if question_s == "<MY QUESTION>":
       a							      =     st.text_input('''Enter your question here:''', '''''')
else:
       a							      =     question_s

if st.button('''Show me!'''):
       if action in [0, 1, 3]:
              if index_type == "mixed":
                     a      ,		a							      =     make_support(question, source=wiki_source, method='''dense''', n_results=10)
                     a      ,		a							      =     make_support(question, source=wiki_source, method='''sparse''', n_results=10)
                     a							      =     []
                     for res_d, res_s in zip(support_list_dense, support_list_sparse):
                            if tuple(res_d) not in support_list:
                                   support_list += [tuple(res_d)]
                            if tuple(res_s) not in support_list:
                                   support_list += [tuple(res_s)]
                     a							      =     support_list[:10]
                     a							      =     '''<P> ''' + ''' <P> '''.join([res[-1] for res in support_list])
              else:
                     a      ,		a							      =     make_support(question, source=wiki_source, method=index_type, n_results=10)
       if action in [0, 3]:
              a      ,		a							      =     answer_question(
                  question_doc,
                  sas_model,
                  sas_tokenizer,
                  min_len=min_len,
                  max_len=int(max_len),
                  sampling=(sampled == '''sampled'''),
                  n_beams=n_beams,
                  top_p=top_p,
                  temp=temp,
              )
              st.markdown('''### The model generated answer is:''')
              st.write(answer)
       if action in [0, 1, 3] and wiki_source != "none":
              st.markdown('''--- \n ### The model is drawing information from the following Wikipedia passages:''')
              for i, res in enumerate(support_list):
                     a							      =     '''https://en.wikipedia.org/wiki/{}'''.format(res[0].replace(''' ''', '''_'''))
                     a							      =     res[1].strip()
                     if sec_titles == "":
                            a							      =     '''[{}]({})'''.format(res[0], wiki_url)
                     else:
                            a							      =     sec_titles.split(''' & ''')
                            a							      =     ''' & '''.join(
                                ['''[{}]({}#{})'''.format(sec.strip(), wiki_url, sec.strip().replace(''' ''', '''_''')) for sec in sec_list]
                            )
                     st.markdown(
                         '''{0:02d} - **Article**: {1:<18} <br>  _Section_: {2}'''.format(i + 1, res[0], sections),
                         unsafe_allow_html=True,
                     )
                     if show_passages:
                            st.write(
                                '''> <span style="font-family:arial; font-size:10pt;">''' + res[-1] + '''</span>''', unsafe_allow_html=True
                            )
       if action in [2, 3]:
              a							      =     find_nearest_training(question)
              a							      =     nn_train_list[0]
              st.markdown(
                  '''--- \n ### The most similar question in the ELI5 training set was: \n\n {}'''.format(train_exple['''title'''])
              )
              a							      =     [
                  '''{}. {}'''.format(i + 1, '''  \n'''.join([line.strip() for line in ans.split('''\n''') if line.strip() != '''''']))
                  for i, (ans, sc) in enumerate(zip(train_exple['''answers''']['''text'''], train_exple['''answers''']['''score''']))
                  if i == 0 or sc > 2
              ]
              st.markdown('''##### Its answers were: \n\n {}'''.format('''\n'''.join(answers_st)))


a							      =     '''
---

**Disclaimer**

*The intent of this app is to provide some (hopefully entertaining) insights into the behavior of a current LFQA system.
Evaluating biases of such a model and ensuring factual generations are still very much open research problems.
Therefore, until some significant progress is achieved, we caution against using the generated answers for practical purposes.*
'''







st.sidebar.markdown(disclaimer, unsafe_allow_html=True)






import logging
import os
import threading
import time


try:
				import warnings
except ImportError:
				__snake_case     :Any			       =None

try:
				import msvcrt
except ImportError:
				__snake_case     :Union[str, Any]			       =None

try:
				import fcntl
except ImportError:
				__snake_case     :str			       =None


# Backward compatibility
# ------------------------------------------------
try:
				TimeoutError
except NameError:
				__snake_case     :str			       =OSError


# Data
# ------------------------------------------------
__snake_case     :Any			       =[
    'Timeout',
    'BaseFileLock',
    'WindowsFileLock',
    'UnixFileLock',
    'SoftFileLock',
    'FileLock',
]

__snake_case     :str			       ='3.0.12'


__snake_case     :str			       =None






def  lowerCamelCase_	(      )       ->							List[str]:

							'''simple docstring'''






							global _logger
							A      						=    _logger or logging.getLogger(__name__				)
							return _logger



class        lowerCAmelCase__					(  _lowerCamelCase       ):


				def __init__(							self      :  Tuple						, __UpperCamelCase      :  Union[str, Any]       )		->     List[Any]:
											A      						=    lock_file
											return None


				def __str__(							self      :  List[Any]       )		->     int:
											A      						=    f'''The file lock \'{self.lock_file}\' could not be acquired.'''
											return temp





class        lowerCAmelCase__					:


				def __init__(							self      :  int						, __UpperCamelCase      :  Union[str, Any]       )		->     List[str]:
											A      						=    lock
											return None


				def __enter__(							self      :  Dict       )		->     Dict:
											return self.lock


				def __exit__(							self      :  int						, __UpperCamelCase      :  str						, __UpperCamelCase      :  Optional[int]						, __UpperCamelCase      :  Any       )		->     Optional[int]:
											self.lock.release()
											return None





class        lowerCAmelCase__					:


				def __init__(							self      :  List[Any]						, __UpperCamelCase      :  List[str]						, __UpperCamelCase      :  List[Any]=-1						, __UpperCamelCase      :  Optional[Any]=None       )		->     Dict:
											A      						=    max_filename_length if max_filename_length is not None else 255
											# Hash the filename if it's too long
											A      						=    self.hash_filename_if_too_long(__UpperCamelCase						, __UpperCamelCase       )
											# The path to the lock file.
											A      						=    lock_file

											# The file descriptor for the *_lock_file* as it is returned by the
											# os.open() function.
											# This file lock is only NOT None, if the object currently holds the
											# lock.
											A      						=    None

											# The default timeout value.
											A      						=    timeout

											# We use this lock primarily for the lock counter.
											A      						=    threading.Lock()

											# The lock counter is used for implementing the nested locking
											# mechanism. Whenever the lock is acquired, the counter is increased and
											# the lock is only released, when this value is 0 again.
											A      						=    0
											return None


				@property
				def __UpperCamelCase						(							self      :  str       )		->     Union[str, Any]:
											return self._lock_file


				@property
				def __UpperCamelCase						(							self      :  Tuple       )		->     Union[str, Any]:
											return self._timeout


				@timeout.setter
				def __UpperCamelCase						(							self      :  Union[str, Any]						, __UpperCamelCase      :  Any       )		->     Tuple:
											A      						=    float(__UpperCamelCase       )
											return None


				def __UpperCamelCase						(							self      :  Optional[Any]       )		->     Any:
											raise NotImplementedError()


				def __UpperCamelCase						(							self      :  int       )		->     str:
											raise NotImplementedError()


				@property
				def __UpperCamelCase						(							self      :  List[Any]       )		->     Optional[Any]:
											return self._lock_file_fd is not None


				def __UpperCamelCase						(							self      :  int						, __UpperCamelCase      :  List[str]=None						, __UpperCamelCase      :  Any=0.0_5       )		->     Any:
											# Use the default timeout, if no timeout is provided.
											if timeout is None:
																		A      						=    self.timeout

											# Increment the number right at the beginning.
											# We can still undo it, if something fails.
											with self._thread_lock:
																		self._lock_counter += 1

											A      						=    id(self       )
											A      						=    self._lock_file
											A      						=    time.time()
											try:
																		while True:
																									with self._thread_lock:
																																if not self.is_locked:
																																							logger().debug(f'''Attempting to acquire lock {lock_id} on {lock_filename}'''       )
																																							self._acquire()

																									if self.is_locked:
																																logger().debug(f'''Lock {lock_id} acquired on {lock_filename}'''       )
																																break
																									elif timeout >= 0 and time.time() - start_time > timeout:
																																logger().debug(f'''Timeout on acquiring lock {lock_id} on {lock_filename}'''       )
																																raise Timeout(self._lock_file       )
																									else:
																																logger().debug(
																																    f'''Lock {lock_id} not acquired on {lock_filename}, waiting {poll_intervall} seconds ...'''       )
																																time.sleep(__UpperCamelCase       )
											except:  # noqa
																		# Something did go wrong, so decrement the counter.
																		with self._thread_lock:
																									A      						=    max(0						, self._lock_counter - 1       )

																		raise
											return _Acquire_ReturnProxy(lock=self       )


				def __UpperCamelCase						(							self      :  Optional[int]						, __UpperCamelCase      :  Tuple=False       )		->     Tuple:
											with self._thread_lock:
																		if self.is_locked:
																									self._lock_counter -= 1

																									if self._lock_counter == 0 or force:
																																A      						=    id(self       )
																																A      						=    self._lock_file

																																logger().debug(f'''Attempting to release lock {lock_id} on {lock_filename}'''       )
																																self._release()
																																A      						=    0
																																logger().debug(f'''Lock {lock_id} released on {lock_filename}'''       )

											return None


				def __enter__(							self      :  int       )		->     Dict:
											self.acquire()
											return self


				def __exit__(							self      :  List[str]						, __UpperCamelCase      :  Dict						, __UpperCamelCase      :  Optional[Any]						, __UpperCamelCase      :  str       )		->     Dict:
											self.release()
											return None


				def __del__(							self      :  Union[str, Any]       )		->     Optional[int]:
											self.release(force=__UpperCamelCase       )
											return None


				def __UpperCamelCase						(							self      :  Union[str, Any]						, __UpperCamelCase      :  str						, __UpperCamelCase      :  int       )		->     str:
											A      						=    os.path.basename(__UpperCamelCase       )
											if len(__UpperCamelCase       ) > max_length and max_length > 0:
																		A      						=    os.path.dirname(__UpperCamelCase       )
																		A      						=    str(hash(__UpperCamelCase       )       )
																		A      						=    filename[: max_length - len(__UpperCamelCase       ) - 8] + '...' + hashed_filename + '.lock'
																		return os.path.join(__UpperCamelCase						, __UpperCamelCase       )
											else:
																		return path





class        lowerCAmelCase__					(  _lowerCamelCase       ):


				def __init__(							self      :  Tuple						, __UpperCamelCase      :  List[str]						, __UpperCamelCase      :  Tuple=-1						, __UpperCamelCase      :  Optional[Any]=None       )		->     Union[str, Any]:
											from .file_utils import relative_to_absolute_path

											super().__init__(__UpperCamelCase						, timeout=__UpperCamelCase						, max_filename_length=__UpperCamelCase       )
											A      						=    '\\\\?\\' + relative_to_absolute_path(self.lock_file       )


				def __UpperCamelCase						(							self      :  Any       )		->     Any:
											A      						=    os.O_RDWR | os.O_CREAT | os.O_TRUNC

											try:
																		A      						=    os.open(self._lock_file						, __UpperCamelCase       )
											except OSError:
																		pass
											else:
																		try:
																									msvcrt.locking(__UpperCamelCase						, msvcrt.LK_NBLCK						, 1       )
																		except OSError:
																									os.close(__UpperCamelCase       )
																		else:
																									A      						=    fd
											return None


				def __UpperCamelCase						(							self      :  Optional[Any]       )		->     List[Any]:
											A      						=    self._lock_file_fd
											A      						=    None
											msvcrt.locking(__UpperCamelCase						, msvcrt.LK_UNLCK						, 1       )
											os.close(__UpperCamelCase       )

											try:
																		os.remove(self._lock_file       )
											# Probably another instance of the application
											# that acquired the file lock.
											except OSError:
																		pass
											return None





class        lowerCAmelCase__					(  _lowerCamelCase       ):


				def __init__(							self      :  List[Any]						, __UpperCamelCase      :  Any						, __UpperCamelCase      :  List[Any]=-1						, __UpperCamelCase      :  Dict=None       )		->     Dict:
											A      						=    os.statvfs(os.path.dirname(__UpperCamelCase       )       ).f_namemax
											super().__init__(__UpperCamelCase						, timeout=__UpperCamelCase						, max_filename_length=__UpperCamelCase       )


				def __UpperCamelCase						(							self      :  Any       )		->     int:
											A      						=    os.O_RDWR | os.O_CREAT | os.O_TRUNC
											A      						=    os.open(self._lock_file						, __UpperCamelCase       )

											try:
																		fcntl.flock(__UpperCamelCase						, fcntl.LOCK_EX | fcntl.LOCK_NB       )
											except OSError:
																		os.close(__UpperCamelCase       )
											else:
																		A      						=    fd
											return None


				def __UpperCamelCase						(							self      :  Optional[int]       )		->     int:
											# Do not remove the lockfile:
											#
											#   https://github.com/benediktschmitt/py-filelock/issues/31
											#   https://stackoverflow.com/questions/17708885/flock-removing-locked-file-without-race-condition
											A      						=    self._lock_file_fd
											A      						=    None
											fcntl.flock(__UpperCamelCase						, fcntl.LOCK_UN       )
											os.close(__UpperCamelCase       )
											return None





class        lowerCAmelCase__					(  _lowerCamelCase       ):


				def __UpperCamelCase						(							self      :  int       )		->     Optional[int]:
											A      						=    os.O_WRONLY | os.O_CREAT | os.O_EXCL | os.O_TRUNC
											try:
																		A      						=    os.open(self._lock_file						, __UpperCamelCase       )
											except OSError:
																		pass
											else:
																		A      						=    fd
											return None


				def __UpperCamelCase						(							self      :  Optional[Any]       )		->     List[str]:
											os.close(self._lock_file_fd       )
											A      						=    None

											try:
																		os.remove(self._lock_file       )
											# The file is already deleted and that's what we want.
											except OSError:
																		pass
											return None





__snake_case     :List[str]			       =None

if msvcrt:
				__snake_case     :List[Any]			       =WindowsFileLock
elif fcntl:
				__snake_case     :Any			       =UnixFileLock
else:
				__snake_case     :Tuple			       =SoftFileLock

				if warnings is not None:
								warnings.warn('only soft file lock is available')