code: def _get_run_error_code(run: Run) -> Optional[JobErrorCode]:
      job = run._run.jobs[0]
      if len(job.job_submissions) == 0:
          return None
      job_submission = job.job_submissions[0]
      return job_submission.error_code
  
imports: import argparse
  import sys
  import time
  from pathlib import Path
  from typing import Optional
  from dstack._internal.cli.commands import APIBaseCommand
  from dstack._internal.cli.services.configurators.profile import apply_profile_args, register_profile_args
  from dstack._internal.cli.services.configurators.run import BaseRunConfigurator, run_configurators_mapping
  from dstack._internal.cli.utils.common import confirm_ask, console
  from dstack._internal.cli.utils.run import print_run_plan
  from dstack._internal.core.errors import CLIError, ConfigurationError, ServerClientError
  from dstack._internal.core.models.configurations import ConfigurationType
  from dstack._internal.core.models.runs import JobErrorCode
  from dstack._internal.core.services.configs import ConfigManager
  from dstack._internal.utils.logging import get_logger
  from dstack.api import RunStatus
  from dstack.api._public.runs import Run
  from dstack.api.utils import load_configuration, load_profile
label_desc: Use image node_id 2 for calling a global function with example usage: _get_run_error_code(run) and returns: job_submission, None