code: def delete_old_branches(obj, dry_run, days, maximum):
      """
      Deletes branches on queue repository (crossbow) that are older than number
      of days.
      With a maximum number of branches to be deleted. This is required to avoid
      triggering GitHub protection limits.
      """
      queue = obj["queue"]
      ts = time.time() - days * 24 * 3600
      refs = []
      for ref in queue.repo.listall_reference_objects():
          commit = ref.peel()
          if commit.commit_time < ts and not ref.name.startswith(
              "refs/remotes/origin/pr/"
          ):
              # Check if reference is a remote reference to point
              # to the remote head.
              ref_name = ref.name
              if ref_name.startswith("refs/remotes/origin"):
                  ref_name = ref_name.replace("remotes/origin", "heads")
              refs.append(f":{ref_name}")
  
      def batch_gen(iterable, step):
          total_length = len(iterable)
          to_delete = min(total_length, maximum)
          print(
              f"Total number of references to be deleted: {to_delete}"
          )
          for index in range(0, to_delete, step):
              yield iterable[index : min(index + step, to_delete)]
  
      for batch in batch_gen(refs, 50):
          if not dry_run:
              queue.push(batch)
          else:
              print(batch)
  
imports: from datetime import date
  from pathlib import Path
  import time
  import sys
  import click
  from .core import Config, Repo, Queue, Target, Job, CrossbowError
  from .reports import ChatReport, Report, ReportUtils, ConsoleReport, EmailReport, CommentReport
  from ..utils.source import ArrowSources
label_desc: Use image node_id 14 for calling a global function with example usage: delete_old_branches(obj, dry_run, days, maximum) without return types