code: def construct_agent_configs(
      launch_config: Optional[Dict] = None,
      build_config: Optional[Dict] = None,
  ) -> Tuple[Optional[Dict[str, Any]], Dict[str, Any], Dict[str, Any]]:
      registry_config = None
      environment_config = None
      if launch_config is not None:
          build_config = launch_config.get("builder")
          registry_config = launch_config.get("registry")
  
      default_launch_config = None
      if os.path.exists(os.path.expanduser(LAUNCH_CONFIG_FILE)):
          with open(os.path.expanduser(LAUNCH_CONFIG_FILE)) as f:
              default_launch_config = (
                  yaml.safe_load(f) or {}
              )  # In case the config is empty, we want it to be {} instead of None.
          environment_config = default_launch_config.get("environment")
  
      build_config, registry_config = resolve_build_and_registry_config(
          default_launch_config, build_config, registry_config
      )
  
      return environment_config, build_config, registry_config
  
imports: import hashlib
  import json
  import logging
  import os
  import shlex
  import shutil
  import sys
  import tempfile
  from typing import Any, Dict, List, Optional, Tuple
  import pkg_resources
  import yaml
  from dockerpycreds.utils import find_executable
  from six.moves import shlex_quote
  import wandb
  import wandb.docker
  import wandb.env
  from wandb.apis.internal import Api
  from wandb.sdk.launch.loader import builder_from_config, environment_from_config, registry_from_config
  from .._project_spec import EntryPoint, EntrypointDefaults, LaunchProject, fetch_and_validate_project
  from ..errors import ExecutionError, LaunchError
  from ..registry.abstract import AbstractRegistry
  from ..utils import AZURE_CONTAINER_REGISTRY_URI_REGEX, ELASTIC_CONTAINER_REGISTRY_URI_REGEX, GCP_ARTIFACT_REGISTRY_URI_REGEX, LAUNCH_CONFIG_FILE, LOG_PREFIX, event_loop_thread_exec, resolve_build_and_registry_config
label_desc: Use image node_id 14 for calling a global function with example usage: construct_agent_configs(launch_config, build_config) and returns: environment_config,  build_config,  registry_config