code: def main(milestone, log_level, verbose, check_only, allow_closed):
      """Generates a bokeh changelog which includes the given milestone.
  
      Requires that you set GH_TOKEN to your GitHub API Token. Exit code 2
      indicates there was a verification problem whereas exit code 1 indicates a general
      error in the script. Otherwise you can expect an exit code of 0 for success.
      """
      log_level = "DEBUG" if verbose else log_level
      logging.basicConfig(level=log_level)
  
      token = os.environ.get("GH_TOKEN", None)
      if not token:
          print("error: GH_TOKEN is not set", file=sys.stderr)
          sys.exit(1)
  
      items = get_milestone_items(milestone, token, allow_closed)
      if not items:
          print(
              f"error: no such milestone: {milestone}", file=sys.stderr
          )
          sys.exit(1)
  
      problems = check_milestone_items(items)
      for problem in problems:
          print(problem, file=sys.stderr)
  
      if len(problems) > 0:
          sys.exit(2)
      elif check_only:
          sys.exit(0)
  
      CHANGELOG = REPO_ROOT / "docs" / "CHANGELOG"
  
      with open(CHANGELOG) as f:
          old_changelog = f.read()
  
      out = open(CHANGELOG, mode="w")
  
      out.write(f"{datetime.date.today()} {milestone:>8}:\n")
      out.write("--------------------\n")
      grouping = lambda item: get_label_type(item) or "none"
      items = sorted(items, key=grouping)
      for group_type, group in groupby(items, grouping):
          if group_type == "bug":
              out.write("  * bugfixes:\n")
          elif group_type == "feature":
              out.write("  * features:\n")
          elif group_type == "task":
              out.write("  * tasks:\n")
          elif group_type == "none":
              continue
          for item in group:
              out.write(f"    - {description(item)}\n")
          out.write("\n")
      out.write(old_changelog)
  
file_path: bokeh/scripts/milestone.py
imports: import datetime
  import logging
  import os
  import sys
  from itertools import groupby
  from pathlib import Path
  import click
  import requests
label_desc: Use image node_id 12 for calling a global function with example usage: main(milestone, log_level, verbose, check_only, allow_closed) without return types