'''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
)
UpperCAmelCase_			    =							logging.getLogger(__name__)

if __name__ == "__main__":
  UpperCAmelCase_			    =							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_0_5_2_2, type=int)
  UpperCAmelCase_			    =							parser.parse_args()

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

  logger.info('''Counting occurrences for MLM.''')
  UpperCAmelCase_			    =							Counter()
  for tk_ids in data:
    counter.update(tk_ids)
  UpperCAmelCase_			    =							[0] * args.vocab_size
  for k, v in counter.items():
    UpperCAmelCase_			    =							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 __future__ import annotations




def       lowerCAmelCase_     (		lowercase:							int = 4		)    ->				list[list[int]]:







 '''simple docstring'''
 _UpperCamelCase:     Dict							= abs(lowercase		) or 4
 return [[1 + x + y * row_size for x in range(lowercase		)] for y in range(lowercase		)]




def       lowerCAmelCase_     (		lowercase:							list[list[int]]		)    ->				list[list[int]]:







 '''simple docstring'''
 return reverse_row(transpose(lowercase		)		)
 # OR.. transpose(reverse_column(matrix))




def       lowerCAmelCase_     (		lowercase:							list[list[int]]		)    ->				list[list[int]]:







 '''simple docstring'''
 return reverse_row(reverse_column(lowercase		)		)
 # OR.. reverse_column(reverse_row(matrix))




def       lowerCAmelCase_     (		lowercase:							list[list[int]]		)    ->				list[list[int]]:







 '''simple docstring'''
 return reverse_column(transpose(lowercase		)		)
 # OR.. transpose(reverse_row(matrix))




def       lowerCAmelCase_     (		lowercase:							list[list[int]]		)    ->				list[list[int]]:







 '''simple docstring'''
 _UpperCamelCase:     int							= [list(lowercase		) for x in zip(*lowercase		)]
 return matrix




def       lowerCAmelCase_     (		lowercase:							list[list[int]]		)    ->				list[list[int]]:







 '''simple docstring'''
 _UpperCamelCase:     str							= matrix[::-1]
 return matrix




def       lowerCAmelCase_     (		lowercase:							list[list[int]]		)    ->				list[list[int]]:







 '''simple docstring'''
 _UpperCamelCase:     str							= [x[::-1] for x in matrix]
 return matrix




def       lowerCAmelCase_     (		lowercase:							list[list[int]]		)    ->				None:







 '''simple docstring'''
 for i in matrix:
  print(*lowercase		)


if __name__ == "__main__":
  UpperCAmelCase_			    =							make_matrix()
  print('''\norigin:\n''')
  print_matrix(matrix)
  print('''\nrotate 90 counterclockwise:\n''')
  print_matrix(rotate_aa(matrix))

  UpperCAmelCase_			    =							make_matrix()
  print('''\norigin:\n''')
  print_matrix(matrix)
  print('''\nrotate 180:\n''')
  print_matrix(rotate_aaa(matrix))

  UpperCAmelCase_			    =							make_matrix()
  print('''\norigin:\n''')
  print_matrix(matrix)
  print('''\nrotate 270 counterclockwise:\n''')
  print_matrix(rotate_aaa(matrix))