class_docstr: Cluster environment for training on a cluster managed by SLURM.
  
  You can configure the `main_address` and `main_port` properties via the env variables `MASTER_ADDR` and
  `MASTER_PORT`, respectively.
  
  Args:
      auto_requeue: Whether automatic job resubmission is enabled or not. How and under which conditions a job gets
          rescheduled gets determined by the owner of this plugin.
      requeue_signal: The signal that SLURM will send to indicate that the job should be requeued. Defaults to
          SIGUSR1 on Unix.
class_docstr_tok: ["Cluster","environment","for","training","on","a","cluster","managed","by","SLURM",".","You","can","configure","the","`","main_address","`","and","`","main_port","`","properties","via","the","env","variables","`","MASTER_ADDR","`","and","`","MASTER_PORT","`",",","respectively",".","Args",":","auto_requeue",":","Whether","automatic","job","resubmission","is","enabled","or","not",".","How","and","under","which","conditions","a","job","gets","rescheduled","gets","determined","by","the","owner","of","this","plugin",".","requeue_signal",":","The","signal","that","SLURM","will","send","to","indicate","that","the","job","should","be","requeued",".","Defaults","to","SIGUSR1","on","Unix","."]
docstr: The node selection format in SLURM supports several formats.
  
  This function selects the first host name from
  
  - a space-separated list of host names, e.g., 'host0 host1 host3' yields 'host0' as the root
  - a comma-separated list of host names, e.g., 'host0,host1,host3' yields 'host0' as the root
  - the range notation with brackets, e.g., 'host[5-9]' yields 'host5' as the root
docstr_tok: ["The","node","selection","format","in","SLURM","supports","several","formats",".","This","function","selects","the","first","host","name","from","-","a","space-separated","list","of","host","names",",","e.g.",",","'host0","host1","host3","'","yields","'host0","'","as","the","root","-","a","comma-separated","list","of","host","names",",","e.g.",",","'host0",",","host1",",","host3","'","yields","'host0","'","as","the","root","-","the","range","notation","with","brackets",",","e.g.",",","'host","[","5-9","]","'","yields","'host5","'","as","the","root"]
code: def resolve_root_node_address(nodes: str) -> str:
      """The node selection format in SLURM supports several formats.
  
      This function selects the first host name from
  
      - a space-separated list of host names, e.g., 'host0 host1 host3' yields 'host0' as the root
      - a comma-separated list of host names, e.g., 'host0,host1,host3' yields 'host0' as the root
      - the range notation with brackets, e.g., 'host[5-9]' yields 'host5' as the root
  
      """
      nodes = re.sub(
          r"\[(.*?)[,-].*\]", "\\1", nodes
      )  # Take the first node of every node range
      nodes = re.sub(
          r"\[(.*?)\]", "\\1", nodes
      )  # handle special case where node range is single number
      return nodes.split(" ")[0].split(",")[0]
  
imports: import logging
  import os
  import re
  import shutil
  import signal
  import sys
  from typing import Optional
  from typing_extensions import override
  from lightning.fabric.plugins.environments.cluster_environment import ClusterEnvironment
  from lightning.fabric.utilities.imports import _IS_WINDOWS
  from lightning.fabric.utilities.rank_zero import rank_zero_warn
  from lightning.fabric.utilities.warnings import PossibleUserWarning
label_desc: Use image node_id 15 for calling the SLURMEnvironment obj's underlying member method code with example usage: obj.resolve_root_node_address(nodes) and returns: nodes