






import random






def 	_UpperCAmelCase    (  a		:	List[Any]							)			->			bool:





						"""simple docstring"""
						lowercase_      :   List[Any]        =			num - 1
						lowercase_      :   Union[str, Any]        =			0

						while s % 2 == 0:
												lowercase_      :   List[Any]        =			s // 2
												t += 1

						for _ in range(5							):
												lowercase_      :   List[str]        =			random.randrange(2						,			num - 1							)
												lowercase_      :   Optional[int]        =			pow(_lowerCAmelCase						,			_lowerCAmelCase						,			_lowerCAmelCase							)
												if v != 1:
																		lowercase_      :   str        =			0
																		while v != (num - 1):
																								if i == t - 1:
																														return False
																								else:
																														lowercase_      :   Any        =			i + 1
																														lowercase_      :   List[str]        =			(v**2) % num
						return True






def 	_UpperCAmelCase    (  a		:	List[Any]							)			->			bool:





						"""simple docstring"""
						if num < 2:
												return False

						lowercase_      :   str        =			[
						    2,
						    3,
						    5,
						    7,
						    1_1,
						    1_3,
						    1_7,
						    1_9,
						    2_3,
						    2_9,
						    3_1,
						    3_7,
						    4_1,
						    4_3,
						    4_7,
						    5_3,
						    5_9,
						    6_1,
						    6_7,
						    7_1,
						    7_3,
						    7_9,
						    8_3,
						    8_9,
						    9_7,
						    1_0_1,
						    1_0_3,
						    1_0_7,
						    1_0_9,
						    1_1_3,
						    1_2_7,
						    1_3_1,
						    1_3_7,
						    1_3_9,
						    1_4_9,
						    1_5_1,
						    1_5_7,
						    1_6_3,
						    1_6_7,
						    1_7_3,
						    1_7_9,
						    1_8_1,
						    1_9_1,
						    1_9_3,
						    1_9_7,
						    1_9_9,
						    2_1_1,
						    2_2_3,
						    2_2_7,
						    2_2_9,
						    2_3_3,
						    2_3_9,
						    2_4_1,
						    2_5_1,
						    2_5_7,
						    2_6_3,
						    2_6_9,
						    2_7_1,
						    2_7_7,
						    2_8_1,
						    2_8_3,
						    2_9_3,
						    3_0_7,
						    3_1_1,
						    3_1_3,
						    3_1_7,
						    3_3_1,
						    3_3_7,
						    3_4_7,
						    3_4_9,
						    3_5_3,
						    3_5_9,
						    3_6_7,
						    3_7_3,
						    3_7_9,
						    3_8_3,
						    3_8_9,
						    3_9_7,
						    4_0_1,
						    4_0_9,
						    4_1_9,
						    4_2_1,
						    4_3_1,
						    4_3_3,
						    4_3_9,
						    4_4_3,
						    4_4_9,
						    4_5_7,
						    4_6_1,
						    4_6_3,
						    4_6_7,
						    4_7_9,
						    4_8_7,
						    4_9_1,
						    4_9_9,
						    5_0_3,
						    5_0_9,
						    5_2_1,
						    5_2_3,
						    5_4_1,
						    5_4_7,
						    5_5_7,
						    5_6_3,
						    5_6_9,
						    5_7_1,
						    5_7_7,
						    5_8_7,
						    5_9_3,
						    5_9_9,
						    6_0_1,
						    6_0_7,
						    6_1_3,
						    6_1_7,
						    6_1_9,
						    6_3_1,
						    6_4_1,
						    6_4_3,
						    6_4_7,
						    6_5_3,
						    6_5_9,
						    6_6_1,
						    6_7_3,
						    6_7_7,
						    6_8_3,
						    6_9_1,
						    7_0_1,
						    7_0_9,
						    7_1_9,
						    7_2_7,
						    7_3_3,
						    7_3_9,
						    7_4_3,
						    7_5_1,
						    7_5_7,
						    7_6_1,
						    7_6_9,
						    7_7_3,
						    7_8_7,
						    7_9_7,
						    8_0_9,
						    8_1_1,
						    8_2_1,
						    8_2_3,
						    8_2_7,
						    8_2_9,
						    8_3_9,
						    8_5_3,
						    8_5_7,
						    8_5_9,
						    8_6_3,
						    8_7_7,
						    8_8_1,
						    8_8_3,
						    8_8_7,
						    9_0_7,
						    9_1_1,
						    9_1_9,
						    9_2_9,
						    9_3_7,
						    9_4_1,
						    9_4_7,
						    9_5_3,
						    9_6_7,
						    9_7_1,
						    9_7_7,
						    9_8_3,
						    9_9_1,
						    9_9_7,
						]

						if num in low_primes:
												return True

						for prime in low_primes:
												if (num % prime) == 0:
																		return False

						return rabin_miller(_lowerCAmelCase							)






def 	_UpperCAmelCase    (  a		:	str = 1_0_2_4							)			->			int:





						"""simple docstring"""
						while True:
												lowercase_      :   Any        =			random.randrange(2 ** (keysize - 1)						,			2 ** (keysize)							)
												if is_prime_low_num(_lowerCAmelCase							):
																		return num


if __name__ == "__main__":
						A:      List[Any]  				=				generate_large_prime()
						print(("Prime number:", num))
						print(("is_prime_low_num:", is_prime_low_num(num)))








'''simple docstring'''

import json
import logging
import os
import socket

import git
import numpy as np
import torch


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






def 	_UpperCAmelCase    (  a		:	str							)			->			List[Any]:





						"""simple docstring"""
						lowercase_      :   List[str]        =			git.Repo(search_parent_directories=a							)
						lowercase_      :   Union[str, Any]        =			{
						    'repo_id': str(a							),
						    'repo_sha': str(repo.head.object.hexsha							),
						    'repo_branch': str(repo.active_branch							),
						}

						with open(os.path.join(a						,			'git_log.json'							)						,			'w'							) as f:
												json.dump(a						,			a						,			indent=4							)






def 	_UpperCAmelCase    (  a		:	str							)			->			Union[str, Any]:





						"""simple docstring"""
						if params.n_gpu <= 0:
												lowercase_      :   int        =			0
												lowercase_      :   Union[str, Any]        =			-1
												lowercase_      :   List[str]        =			True
												lowercase_      :   Optional[Any]        =			False
												return

						assert torch.cuda.is_available()

						logger.info('Initializing GPUs'							)
						if params.n_gpu > 1:
												assert params.local_rank != -1

												lowercase_      :   Dict        =			int(os.environ['WORLD_SIZE']							)
												lowercase_      :   Union[str, Any]        =			int(os.environ['N_GPU_NODE']							)
												lowercase_      :   Optional[int]        =			int(os.environ['RANK']							)

												# number of nodes / node ID
												lowercase_      :   int        =			params.world_size // params.n_gpu_per_node
												lowercase_      :   str        =			params.global_rank // params.n_gpu_per_node
												lowercase_      :   Dict        =			True

												assert params.n_nodes == int(os.environ['N_NODES']							)
												assert params.node_id == int(os.environ['NODE_RANK']							)

						# local job (single GPU)
						else:
												assert params.local_rank == -1

												lowercase_      :   str        =			1
												lowercase_      :   Dict        =			0
												lowercase_      :   Tuple        =			0
												lowercase_      :   List[Any]        =			0
												lowercase_      :   int        =			1
												lowercase_      :   Tuple        =			1
												lowercase_      :   str        =			False

						# sanity checks
						assert params.n_nodes >= 1
						assert 0 <= params.node_id < params.n_nodes
						assert 0 <= params.local_rank <= params.global_rank < params.world_size
						assert params.world_size == params.n_nodes * params.n_gpu_per_node

						# define whether this is the master process / if we are in multi-node distributed mode
						lowercase_      :   List[str]        =			params.node_id == 0 and params.local_rank == 0
						lowercase_      :   Optional[Any]        =			params.n_nodes > 1

						# summary
						lowercase_      :   int        =			f"--- Global rank: {params.global_rank} - "
						logger.info(PREFIX + 'Number of nodes: %i' % params.n_nodes							)
						logger.info(PREFIX + 'Node ID        : %i' % params.node_id							)
						logger.info(PREFIX + 'Local rank     : %i' % params.local_rank							)
						logger.info(PREFIX + 'World size     : %i' % params.world_size							)
						logger.info(PREFIX + 'GPUs per node  : %i' % params.n_gpu_per_node							)
						logger.info(PREFIX + 'Master         : %s' % str(params.is_master							)							)
						logger.info(PREFIX + 'Multi-node     : %s' % str(params.multi_node							)							)
						logger.info(PREFIX + 'Multi-GPU      : %s' % str(params.multi_gpu							)							)
						logger.info(PREFIX + 'Hostname       : %s' % socket.gethostname()							)

						# set GPU device
						torch.cuda.set_device(params.local_rank							)

						# initialize multi-GPU
						if params.multi_gpu:
												logger.info('Initializing PyTorch distributed'							)
												torch.distributed.init_process_group(
												    init_method='env://'						,			backend='nccl'						,			)






def 	_UpperCAmelCase    (  a		:	Dict							)			->			Optional[int]:





						"""simple docstring"""
						np.random.seed(args.seed							)
						torch.manual_seed(args.seed							)
						if args.n_gpu > 0:
												torch.cuda.manual_seed_all(args.seed							)
