code: def _set_from_slurm_env(self):
      # logger.info("Initialization from Slurm environment")
      job_id = int(os.environ["SLURM_JOB_ID"])
      node_count = int(os.environ["SLURM_JOB_NUM_NODES"])
      nodes = _parse_slurm_node_list(os.environ["SLURM_JOB_NODELIST"])
      assert len(nodes) == node_count
  
      self.master_addr = nodes[0]
      self.master_port = _get_master_port(seed=job_id)
      self.rank = int(os.environ["SLURM_PROCID"])
      self.world_size = int(os.environ["SLURM_NTASKS"])
      assert self.rank < self.world_size
      self.local_rank = int(os.environ["SLURM_LOCALID"])
      self.local_world_size = self.world_size // node_count
      assert self.local_rank < self.local_world_size
  
imports: import os
  import random
  import re
  import socket
  from typing import Dict, List
  import torch
  import torch.distributed
label_desc: Use image node_id 2 for calling the _TorchDistributedEnvironment obj's underlying member method code with example usage: obj._set_from_slurm_env() without return types