






"""simple docstring"""



import os
import sys
import time

from . import transposition_cipher as trans_cipher




def       snake_case__		(   )    ->None:
 UpperCAmelCase__ 						=				"""Prehistoric Men.txt"""
 UpperCAmelCase__ 						=				"""Output.txt"""
 UpperCAmelCase__ 						=				int(input("""Enter key: """			)			)
 UpperCAmelCase__ 						=				input("""Encrypt/Decrypt [e/d]: """			)

 if not os.path.exists(_SCREAMING_SNAKE_CASE			):
  print(F'''File {input_file} does not exist. Quitting...'''			)
  sys.exit()
 if os.path.exists(_SCREAMING_SNAKE_CASE			):
  print(F'''Overwrite {output_file}? [y/n]'''			)
  UpperCAmelCase__ 						=				input("""> """			)
  if not response.lower().startswith("""y"""			):
   sys.exit()

 UpperCAmelCase__ 						=				time.time()
 if mode.lower().startswith("""e"""			):
  with open(_SCREAMING_SNAKE_CASE			) as f:
   UpperCAmelCase__ 						=				f.read()
  UpperCAmelCase__ 						=				trans_cipher.encrypt_message(_SCREAMING_SNAKE_CASE       ,	_SCREAMING_SNAKE_CASE			)
 elif mode.lower().startswith("""d"""			):
  with open(_SCREAMING_SNAKE_CASE			) as f:
   UpperCAmelCase__ 						=				f.read()
  UpperCAmelCase__ 						=				trans_cipher.decrypt_message(_SCREAMING_SNAKE_CASE       ,	_SCREAMING_SNAKE_CASE			)

 with open(_SCREAMING_SNAKE_CASE       ,	"""w"""			) as output_obj:
  output_obj.write(_SCREAMING_SNAKE_CASE			)

 UpperCAmelCase__ 						=				round(time.time() - start_time       ,	2			)
 print(("""Done (""", total_time, """seconds )""")			)


if __name__ == "__main__":
 main()











"""simple docstring"""



import json
import logging
import os
import subprocess
from argparse import ArgumentParser


a  :						Dict					       =							logging.getLogger(__name__)




def       snake_case__		(   )    ->Any:
 UpperCAmelCase__ 						=				ArgumentParser()
 UpperCAmelCase__						,	UpperCAmelCase__ 						=				parser.parse_known_args()
 for arg in unknown:
  if arg.startswith(("""-""", """--""")			):
   parser.add_argument(arg.split("""="""			)[0]			)

 return parser.parse_args()




def       snake_case__		(   )    ->List[Any]:
 UpperCAmelCase__ 						=				parse_args()
 UpperCAmelCase__ 						=				8_8_8_8
 UpperCAmelCase__ 						=				int(os.environ["""SM_NUM_GPUS"""]			)
 UpperCAmelCase__ 						=				json.loads(os.environ["""SM_HOSTS"""]			)
 UpperCAmelCase__ 						=				len(_SCREAMING_SNAKE_CASE			)
 UpperCAmelCase__ 						=				os.environ["""SM_CURRENT_HOST"""]
 UpperCAmelCase__ 						=				hosts.index(_SCREAMING_SNAKE_CASE			)
 UpperCAmelCase__ 						=				"""INFO"""

 if num_nodes > 1:
  UpperCAmelCase__ 						=				F'''python -m torch.distributed.launch \
                --nnodes={num_nodes}  \
                --node_rank={rank}  \
                --nproc_per_node={num_gpus}  \
                --master_addr={hosts[0]}  \
                --master_port={port} \
                ./run_glue.py \
                {''.join(['nested fstring' for parameter,value in args.__dict__.items()]			)}'''
 else:
  UpperCAmelCase__ 						=				F'''python -m torch.distributed.launch \
            --nproc_per_node={num_gpus}  \
            ./run_glue.py \
            {''.join(['nested fstring' for parameter,value in args.__dict__.items()]			)}'''
 try:
  subprocess.run(_SCREAMING_SNAKE_CASE       ,	shell=_SCREAMING_SNAKE_CASE			)
 except Exception as e:
  logger.info(_SCREAMING_SNAKE_CASE			)


if __name__ == "__main__":
 main()



