code: def _get_resubmit_jobs(
      session: Session,
      xgroup: str,
      user: str,
      all_jobs: bool,
  ) -> Optional[List[Job]]:
      """gets jobs for resubmission"""
  
      xg = (
          session.query(ExperimentGroup)
          .filter(
              ExperimentGroup.user == user,
              ExperimentGroup.name == xgroup,
          )
          .first()
      )
  
      if xg is None:
          logging.error(f"could not find experiment group {xgroup}")
          return None
  
      # we get the most recent job for each experiment
      # note that these are already ordered by creation time
      jobs = []
      for e in xg.experiments:
          if len(e.jobs) > 0:
              jobs.append(e.jobs[-1])
  
      if len(jobs) == 0:
          logging.error(f"no jobs found in experiment group")
          return None
  
      # we are only resubmitting stopped or failed jobs
      if not all_jobs:
          jobs = list(
              filter(
                  lambda x: update_job_status(x)
                  in [JobStatus.FAILED, JobStatus.STOPPED],
                  jobs,
              )
          )
  
      if len(jobs) == 0:
          logging.error(f"no jobs found in FAILED or STOPPED state")
          return None
  
      return jobs
  
imports: import logging
  import os
  from typing import Any, Dict, Iterable, List, Optional
  from sqlalchemy import or_
  from sqlalchemy.orm import Session
  from caliban.docker.build import build_image
  from caliban.docker.push import push_uuid_tag
  from caliban.history.submit import submit_job_specs
  from caliban.history.types import ContainerSpec, Experiment, ExperimentGroup, Job, JobStatus, Platform
  from caliban.history.util import get_gke_job_name, get_sql_engine, replace_job_spec_image, session_scope, stop_job, update_job_status
  from caliban.platform.gke.util import credentials, user_verify
  from caliban.util import Package, current_user
label_desc: Use image node_id 11 for calling a global function with example usage: _get_resubmit_jobs(session, xgroup, user, all_jobs) and returns: jobs, None, None, None