code: def _config_to_internal_config(
      backend_config: BackendConfig,
  ) -> AnyConfigInfoWithCreds:
      config_info = _ConfigInfoWithCreds.parse_obj(
          backend_config.dict()
      )
      if backend_config.type == "azure":
          config_info.__root__.locations = backend_config.regions
      return config_info.__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 2 for calling a global function with example usage: _config_to_internal_config(backend_config) and returns: config_info