






'''simple docstring'''




import fcntl
import os
import socket

import torch
import torch.distributed as dist

def 						__UpperCAmelCase							(			*__magic_name__    )->     Tuple:



			"""simple docstring"""



			with open(lowerCAmelCase_  ,"r"    ) as fh:
						fcntl.flock(lowerCAmelCase_  ,fcntl.LOCK_EX    )
						try:
									print(*lowerCAmelCase_    )
						finally:
									fcntl.flock(lowerCAmelCase_  ,fcntl.LOCK_UN    )


__lowerCamelCase :       str 				=       int(os.environ['''LOCAL_RANK'''])
torch.cuda.set_device(local_rank)
__lowerCamelCase :       Union[str, Any] 				=       torch.device('''cuda''', local_rank)
__lowerCamelCase :       int 				=       socket.gethostname()

__lowerCamelCase :       List[str] 				=       f'''[{hostname}-{local_rank}]'''

try:
		# test distributed
		dist.init_process_group('''nccl''')
		dist.all_reduce(torch.ones(1).to(device), op=dist.ReduceOp.SUM)
		dist.barrier()

		# test cuda is available and can allocate memory
		torch.cuda.is_available()
		torch.ones(1).cuda(local_rank)

		# global rank
		__lowerCamelCase :       List[str] 				=       dist.get_rank()
		__lowerCamelCase :       Union[str, Any] 				=       dist.get_world_size()

		printflock(f'''{gpu} is OK (global rank: {rank}/{world_size})''')

		dist.barrier()
		if rank == 0:
				printflock(f'''pt={torch.__version__}, cuda={torch.version.cuda}, nccl={torch.cuda.nccl.version()}''')

except Exception:
		printflock(f'''{gpu} is broken''')
		raise









"""simple docstring"""






from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available


snake_case   					=				{'''tokenization_herbert''': ['''HerbertTokenizer''']}

try:
     if not is_tokenizers_available():
          raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
     pass
else:
     snake_case   					=				['''HerbertTokenizerFast''']


if TYPE_CHECKING:
     from .tokenization_herbert import HerbertTokenizer

     try:
          if not is_tokenizers_available():
               raise OptionalDependencyNotAvailable()
     except OptionalDependencyNotAvailable:
          pass
     else:
          from .tokenization_herbert_fast import HerbertTokenizerFast

else:
     import sys

     snake_case   					=				_LazyModule(__name__, globals()['''__file__'''], _import_structure, module_spec=__spec__)





