code: def resolve_jira_issue(merge_branches, comment, default_jira_id=""):
      issue = get_jira_issue("Enter a JIRA id", default_jira_id)
      if issue is None:
          return
  
      if issue.fields.assignee is None:
          choose_jira_assignee(issue)
  
      versions = asf_jira.project_versions("SPARK")
      # Consider only x.y.z, unreleased, unarchived versions
      versions = [
          x
          for x in versions
          if not x.raw["released"]
          and not x.raw["archived"]
          and re.match(r"\d+\.\d+\.\d+", x.name)
      ]
      versions = sorted(versions, key=lambda x: x.name, reverse=True)
  
      default_fix_versions = []
      for b in merge_branches:
          if b == "master":
              default_fix_versions.append(versions[0].name)
          else:
              found = False
              found_versions = []
              for v in versions:
                  if v.name.startswith(b.replace("branch-", "")):
                      found_versions.append(v.name)
                      found = True
              if found:
                  # There might be several unreleased versions for specific branches
                  # For example, assuming
                  # versions = ['4.0.0', '3.5.1', '3.5.0', '3.4.2', '3.3.4', '3.3.3']
                  # we've found two candidates for branch-3.5, we pick the last/smallest one
                  default_fix_versions.append(found_versions[-1])
              else:
                  print(
                      "Target version for %s is not found on JIRA, it may be archived or "
                      "not created. Skipping it." % b
                  )
  
      for v in default_fix_versions:
          # Handles the case where we have forked a release branch but not yet made the release.
          # In this case, if the PR is committed to the master branch and the release branch, we
          # only consider the release branch to be the fix version. E.g. it is not valid to have
          # both 1.1.0 and 1.0.0 as fix versions.
          (major, minor, patch) = v.split(".")
          if patch == "0":
              previous = "%s.%s.%s" % (major, int(minor) - 1, 0)
              if previous in default_fix_versions:
                  default_fix_versions = list(
                      filter(lambda x: x != v, default_fix_versions)
                  )
      default_fix_versions = ",".join(default_fix_versions)
  
      available_versions = set(list(map(lambda v: v.name, versions)))
      while True:
          try:
              fix_versions = input(
                  "Enter comma-separated fix version(s) [%s]: "
                  % default_fix_versions
              )
              if fix_versions == "":
                  fix_versions = default_fix_versions
              fix_versions = fix_versions.replace(" ", "").split(",")
              if set(fix_versions).issubset(available_versions):
                  break
              else:
                  print(
                      "Specified version(s) [%s] not found in the available versions, try "
                      "again (or leave blank and fix manually)."
                      % (", ".join(fix_versions))
                  )
          except KeyboardInterrupt:
              raise
          except BaseException:
              traceback.print_exc()
              print(
                  "Error setting fix version(s), try again (or leave blank and fix manually)"
              )
  
      def get_version_json(version_str):
          return list(
              filter(lambda v: v.name == version_str, versions)
          )[0].raw
  
      jira_fix_versions = list(
          map(lambda v: get_version_json(v), fix_versions)
      )
  
      resolve = list(
          filter(
              lambda a: a["name"] == "Resolve Issue",
              asf_jira.transitions(issue.key),
          )
      )[0]
      resolution = list(
          filter(
              lambda r: r.raw["name"] == "Fixed", asf_jira.resolutions()
          )
      )[0]
      asf_jira.transition_issue(
          issue.key,
          resolve["id"],
          fixVersions=jira_fix_versions,
          comment=comment,
          resolution={"id": resolution.raw["id"]},
      )
  
      try:
          print_jira_issue_summary(asf_jira.issue(issue.key))
      except Exception:
          print(
              "Unable to fetch JIRA issue %s after resolving"
              % issue.key
          )
      print(
          "Successfully resolved %s with fixVersions=%s!"
          % (issue.key, fix_versions)
      )
  
imports: import json
  import os
  import re
  import subprocess
  import sys
  import traceback
  from urllib.request import urlopen
  from urllib.request import Request
  from urllib.error import HTTPError
label_desc: Use image node_id 10 for calling a global function with example usage: resolve_jira_issue(merge_branches, comment, default_jira_id) and returns: list