code: def load_profile(
      repo_dir: PathLike, profile_name: Optional[str]
  ) -> Profile:
      """
      Loads a profile from `.dstack/profiles.yml`. If `profile_name` is not specified, the default profile is loaded.
      :param repo_dir: The path to the repository root directory.
      :param profile_name: The name of the profile to load.
      :return: Loaded profile.
      """
      repo_dir = Path(repo_dir)
      profiles_path = repo_dir / ".dstack/profiles.yml"
      if not profiles_path.exists():
          profiles_path = profiles_path.with_suffix(".yaml")
  
      config = ProfilesConfig(profiles=[])
      try:
          with profiles_path.open("r") as f:
              config = ProfilesConfig.parse_obj(yaml.safe_load(f))
      except FileNotFoundError:
          pass
  
      if profile_name is None:
          return config.default()
      try:
          return config.get(profile_name)
      except KeyError:
          raise ConfigurationError(f"No such profile: {profile_name}")
  
file_path: dstack/src/dstack/api/utils.py
imports: from pathlib import Path
  from typing import Optional, Tuple
  import yaml
  from dstack._internal.core.errors import ConfigurationError
  from dstack._internal.core.models.configurations import AnyRunConfiguration, BaseConfiguration
  from dstack._internal.core.models.configurations import parse
  from dstack._internal.core.models.profiles import Profile, ProfilesConfig
  from dstack._internal.utils.path import PathLike, path_in_dir
label_desc: Use image node_id 1 for calling a global function with example usage: load_profile(repo_dir, profile_name) and returns: config, config