code: def _patched_run_job(config, task_function, *args, **kwargs):
      # noinspection PyBroadException
      try:
          from hydra.core.utils import JobStatus
  
          failed_status = JobStatus.FAILED
      except Exception:
          LoggerRoot.get_base_logger().warning(
              "Could not import JobStatus from Hydra. Failed tasks will be marked as completed"
          )
          failed_status = None
  
      hydra_context = kwargs.get(
          "hydra_context", PatchHydra._default_hydra_context
      )
      # store the config
      # noinspection PyBroadException
      try:
          if not running_remotely():
              # note that we fetch the overrides from the backend in hydra run when running remotely,
              # here we just get them from hydra to be stored as configuration/parameters
              overrides = config.hydra.overrides.task
              stored_config = {}
              for arg in overrides:
                  if not PatchHydra._is_group(hydra_context, arg):
                      arg = arg.lstrip("+")
                  if "=" in arg:
                      k, v = arg.split("=", 1)
                      stored_config[k] = v
                  else:
                      stored_config[arg] = None
              stored_config[
                  PatchHydra._parameter_allow_full_edit
              ] = False
              if PatchHydra._current_task:
                  PatchHydra._current_task.connect(
                      stored_config, name=PatchHydra._parameter_section
                  )
                  PatchHydra._last_untracked_state.pop("connect", None)
              else:
                  PatchHydra._last_untracked_state["connect"] = dict(
                      mutable=stored_config,
                      name=PatchHydra._parameter_section,
                  )
              PatchHydra._should_delete_overrides = True
      except Exception:
          pass
  
      pre_app_task_init_call = bool(PatchHydra._current_task)
  
      if pre_app_task_init_call and not running_remotely():
          LoggerRoot.get_base_logger(PatchHydra).info(
              "Task.init called outside of Hydra-App. For full Hydra multi-run support, "
              "move the Task.init call into the Hydra-App main function"
          )
  
      kwargs["config"] = config
      kwargs["task_function"] = partial(
          PatchHydra._patched_task_function,
          task_function,
      )
      result = PatchHydra._original_run_job(*args, **kwargs)
      # noinspection PyBroadException
      try:
          result_status = result.status
      except Exception:
          LoggerRoot.get_base_logger(PatchHydra).warning(
              "Could not get Hydra job status. Failed tasks will be marked as completed"
          )
          result_status = None
  
      # if we have Task.init called inside the App, we close it after the app is done.
      # This will make sure that hydra run will create multiple Tasks
      if (
          not running_remotely()
          and not pre_app_task_init_call
          and PatchHydra._current_task
          and (
              failed_status is None
              or result_status is None
              or result_status != failed_status
          )
      ):
          PatchHydra._current_task.close()
          # make sure we do not reuse the Task if we have a multi-run session
          DEV_TASK_NO_REUSE.set(True)
          PatchHydra._current_task = None
  
      return result
  
file_path: clearml/clearml/binding/hydra_bind.py
imports: import io
  import sys
  from functools import partial
  from ..config import running_remotely, get_remote_task_id, DEV_TASK_NO_REUSE
  from ..debugging.log import LoggerRoot
label_desc: Use image node_id 7 for calling the PatchHydra obj's underlying member method code with example usage: obj._patched_run_job(config, task_function) and returns: result