code: def _internal_config_to_config(
      config_info: AnyConfigInfoWithCreds,
  ) -> BackendConfig:
      backend_config = _BackendConfig.parse_obj(
          config_info.dict(exclude={"locations"})
      )
      if config_info.type == "azure":
          backend_config.__root__.regions = config_info.locations
      return backend_config.__root__
  
imports: from pathlib import Path
  from typing import List, Literal, Optional, Union
  import yaml
  from pydantic import BaseModel, Field, root_validator
  from sqlalchemy.ext.asyncio import AsyncSession
  from typing_extensions import Annotated
  from dstack._internal.core.models.backends import AnyConfigInfoWithCreds
  from dstack._internal.core.models.backends.aws import AnyAWSCreds
  from dstack._internal.core.models.backends.azure import AnyAzureCreds
  from dstack._internal.core.models.backends.base import BackendType
  from dstack._internal.core.models.backends.datacrunch import AnyDataCrunchCreds
  from dstack._internal.core.models.backends.lambdalabs import AnyLambdaCreds
  from dstack._internal.core.models.backends.tensordock import AnyTensorDockCreds
  from dstack._internal.core.models.backends.vastai import AnyVastAICreds
  from dstack._internal.core.models.common import ForbidExtra
  from dstack._internal.server import settings
  from dstack._internal.server.models import ProjectModel
  from dstack._internal.server.services import backends
  from dstack._internal.server.services import projects
  from dstack._internal.server.utils.common import run_async
  from dstack._internal.utils.logging import get_logger
label_desc: Use image node_id 1 for calling a global function with example usage: _internal_config_to_config(config_info) and returns: backend_config