task_index = int(os.environ['SLURM_PROCID'])
n_tasks = int(os.environ['SLURM_NPROCS'])
tf_hostlist = [('%s:22222' % host) for host in expand_hostlist(os.environ[
    'SLURM_NODELIST'])]
Running TensorFlow on a Slurm Cluster?