


"""simple docstring"""


import argparse
import logging
import pickle
from collections import Counter


logging.basicConfig(
    format="%(asctime)s - %(levelname)s - %(name)s - %(message)s", datefmt="%m/%d/%Y %H:%M:%S", level=logging.INFO
)
_snake_case        =				logging.getLogger(__name__)

if __name__ == "__main__":
   _snake_case        =				argparse.ArgumentParser(
       description="Token Counts for smoothing the masking probabilities in MLM (cf XLM/word2vec)"
   )
   parser.add_argument(
       "--data_file", type=str, default="data/dump.bert-base-uncased.pickle", help="The binarized dataset."
   )
   parser.add_argument(
       "--token_counts_dump", type=str, default="data/token_counts.bert-base-uncased.pickle", help="The dump file."
   )
   parser.add_argument("--vocab_size", default=3_0522, type=int)
   _snake_case        =				parser.parse_args()

   logger.info(f"""Loading data from {args.data_file}""")
   with open(args.data_file, "rb") as fp:
      _snake_case        =				pickle.load(fp)

   logger.info("Counting occurrences for MLM.")
   _snake_case        =				Counter()
   for tk_ids in data:
      counter.update(tk_ids)
   _snake_case        =				[0] * args.vocab_size
   for k, v in counter.items():
      _snake_case        =				v

   logger.info(f"""Dump to {args.token_counts_dump}""")
   with open(args.token_counts_dump, "wb") as handle:
      pickle.dump(counts, handle, protocol=pickle.HIGHEST_PROTOCOL)







from math import factorial



def       _lowerCAmelCase    (				lowerCAmelCase_				:int = 20				)->int:
   '''simple docstring'''






   snake_case_            =       2 * n  # middle entry of odd rows starting at row 3 is the solution for n = 1,
   # 2, 3,...
   snake_case_            =       n // 2

   return int(factorial(lowerCAmelCase_				) / (factorial(lowerCAmelCase_				) * factorial(n - k				))				)


if __name__ == "__main__":
   import sys

   if len(sys.argv) == 1:
      print(solution(20))
   else:
      try:
         SCREAMING_SNAKE_CASE						:Any			=  int(sys.argv[1])
         print(solution(n))
      except ValueError:
         print('''Invalid entry - please enter a number.''')




