code: def create_project_from_spec(
      launch_spec: Dict[str, Any], api: Api
  ) -> LaunchProject:
      """Constructs a LaunchProject instance using a launch spec.
  
      Arguments:
      launch_spec: Dictionary representation of launch spec
      api: Instance of wandb.apis.internal Api
  
      Returns:
          An initialized `LaunchProject` object
      """
      name: Optional[str] = None
      if launch_spec.get("name"):
          name = launch_spec["name"]
      return LaunchProject(
          launch_spec.get("uri"),
          launch_spec.get("job"),
          api,
          launch_spec,
          launch_spec["entity"],
          launch_spec["project"],
          name,
          launch_spec.get("docker", {}),
          launch_spec.get("git", {}),
          launch_spec.get("overrides", {}),
          launch_spec.get("resource", None),
          launch_spec.get("resource_args", {}),
          launch_spec.get("run_id", None),
          launch_spec.get("sweep_id", {}),
      )
  
imports: import enum
  import json
  import logging
  import os
  import tempfile
  from copy import deepcopy
  from typing import TYPE_CHECKING, Any, Dict, List, Optional, cast
  import wandb
  import wandb.docker
  from wandb.apis.internal import Api
  from wandb.errors import CommError
  from wandb.sdk.launch import utils
  from wandb.sdk.lib.runid import generate_id
  from .errors import LaunchError
  from .utils import LOG_PREFIX, recursive_macro_sub
label_desc: Use image node_id 2 for calling a global function with example usage: create_project_from_spec(launch_spec, api) and returns: LaunchProject