class_docstr: A manager of clusters
  
  Wraps Cluster, adding lookup/list by cluster id
docstr: Populate a ClusterManager from cluster files on disk
  
  Load all cluster objects from the given profile directory(ies).
  
  Default is to find clusters in all IPython profiles,
  but profile directories or profile names can be specified explicitly.
  
  If `init_default_clusters` is True,
  a stopped Cluster object is loaded for every profile dir
  with cluster_id="" if no running cluster is found.
  
  Priority:
  
  - profile_dirs list
  - single profile_dir
  - profiles list by name
  - single profile by name
  - all IPython profiles, if nothing else specified
docstr_tok: ["Populate","a","ClusterManager","from","cluster","files","on","disk","Load","all","cluster","objects","from","the","given","profile","directory","(","ies",")",".","Default","is","to","find","clusters","in","all","IPython","profiles",",","but","profile","directories","or","profile","names","can","be","specified","explicitly",".","If","`","init_default_clusters","`","is","True",",","a","stopped","Cluster","object","is","loaded","for","every","profile","dir","with","cluster_id=","''","''","if","no","running","cluster","is","found",".","Priority",":","-","profile_dirs","list","-","single","profile_dir","-","profiles","list","by","name","-","single","profile","by","name","-","all","IPython","profiles",",","if","nothing","else","specified"]
code: def load_clusters(
      self,
      *,
      profile_dirs=None,
      profile_dir=None,
      profiles=None,
      profile=None,
      init_default_clusters=False,
      **kwargs,
  ):
      """Populate a ClusterManager from cluster files on disk
  
      Load all cluster objects from the given profile directory(ies).
  
      Default is to find clusters in all IPython profiles,
      but profile directories or profile names can be specified explicitly.
  
      If `init_default_clusters` is True,
      a stopped Cluster object is loaded for every profile dir
      with cluster_id="" if no running cluster is found.
  
      Priority:
  
      - profile_dirs list
      - single profile_dir
      - profiles list by name
      - single profile by name
      - all IPython profiles, if nothing else specified
      """
  
      # first, check our current clusters
      for key, cluster in list(self.clusters.items()):
          # remove stopped clusters
          # but not *new* clusters that haven't started yet
          # if `cluster.controller` is present
          # that means it was running at some point
          if cluster.controller and not cluster._is_running():
              self.log.info(f"Removing stopped cluster {key}")
              self.clusters.pop(key)
  
      if profile_dirs is None:
          if profile_dir is not None:
              profile_dirs = [profile_dir]
          else:
              if profiles is None:
                  if profile is not None:
                      profiles = [profile]
  
              if profiles is not None:
                  profile_dirs = _locate_profiles(profiles)
  
          if profile_dirs is None:
              # totally unspecified, default to all
              profile_dirs = _all_profile_dirs()
  
      by_cluster_file = {
          c.cluster_file: c for c in self.clusters.values()
      }
      for profile_dir in profile_dirs:
          cluster_files = self._cluster_files_in_profile_dir(
              profile_dir
          )
          # load default cluster for each profile
          # TODO: only if it has any ipyparallel config files
          # *or* it's the default profile
          if init_default_clusters and not cluster_files:
              cluster = Cluster(profile_dir=profile_dir, cluster_id="")
              cluster_key = self._cluster_key(cluster)
              if cluster_key not in self.clusters:
                  self.clusters[cluster_key] = cluster
  
          for cluster_file in cluster_files:
              if cluster_file in by_cluster_file:
                  # already loaded, skip it
                  continue
              self.log.debug(f"Loading cluster file {cluster_file}")
              try:
                  cluster = Cluster.from_file(cluster_file, parent=self)
              except Exception as e:
                  self.log.warning(
                      f"Failed to load cluster from {cluster_file}: {e}"
                  )
                  continue
              else:
                  cluster_key = self._cluster_key(cluster)
                  self.clusters[cluster_key] = cluster
  
      return self.clusters
  
imports: import asyncio
  import atexit
  import glob
  import inspect
  import json
  import logging
  import os
  import random
  import string
  import sys
  import time
  import traceback
  from functools import partial
  from multiprocessing import cpu_count
  from weakref import WeakSet
  import IPython
  from traitlets import Any, Bool, Dict, Float, Instance, Integer, List, Unicode, default, import_item, validate
  from traitlets.config import Application, Config, LoggingConfigurable
  from .._async import AsyncFirst
  from ..traitlets import Launcher
  from ..util import _all_profile_dirs, _default_profile_dir, _locate_profiles, _traitlet_signature, abbreviate_profile_dir
  from .None import launcher
label_desc: Use image node_id 3 for calling the ClusterManager obj's underlying member method code with example usage: obj.load_clusters() and returns: self