code: def push_and_tag_images(
      py_versions: List[str],
      image_types: List[str],
      merge_build: bool = False,
      release_pr_build: bool = False,
      image_list: Optional[List[str]] = None,
      suffix: Optional[str] = None,
  ):
      date_tag = datetime.datetime.now().strftime("%Y-%m-%d")
      sha_tag = _COMMIT_SHA
      if _release_build():
          release_name = _BRANCH[len("releases/") :]
          date_tag = release_name + "." + date_tag
          sha_tag = release_name + "." + sha_tag
      if release_pr_build:
          pr = f"pr-{os.environ['BUILDKITE_PULL_REQUEST']}"
          date_tag = pr + "." + date_tag
          sha_tag = pr + "." + sha_tag
  
      for image_name in image_list:
          full_image_name = f"rayproject/{image_name}"
  
          tag_mapping = create_image_tags(
              image_name=image_name,
              py_versions=py_versions,
              image_types=image_types,
              specific_tag=date_tag
              if "-deps" in image_name
              else sha_tag,
              version="nightly",
              suffix=suffix,
          )
  
          print(
              f"These tags will be created for {image_name}: ",
              tag_mapping,
          )
  
          # Sanity checking.
          for old_tag in tag_mapping.keys():
              if DEFAULT_PYTHON_VERSION in old_tag:
                  if "-cpu" in old_tag:
                      assert (
                          _with_suffix("nightly-cpu", suffix=suffix)
                          in tag_mapping[old_tag]
                      )
                      if "-deps" in image_name:
                          assert (
                              _with_suffix("nightly", suffix=suffix)
                              in tag_mapping[old_tag]
                          )
                          assert (
                              _with_suffix(
                                  f"{date_tag}-cpu", suffix=suffix
                              )
                              in tag_mapping[old_tag]
                          )
                          assert (
                              _with_suffix(f"{date_tag}", suffix=suffix)
                              in tag_mapping[old_tag]
                          )
                      elif image_name == "ray":
                          assert (
                              _with_suffix("nightly", suffix=suffix)
                              in tag_mapping[old_tag]
                          )
                          assert (
                              _with_suffix(
                                  f"{sha_tag}-cpu", suffix=suffix
                              )
                              in tag_mapping[old_tag]
                          )
                          assert (
                              _with_suffix(f"{sha_tag}", suffix=suffix)
                              in tag_mapping[old_tag]
                          )
                      # For ray-ml, nightly should refer to the GPU image.
                      elif image_name == "ray-ml":
                          assert (
                              _with_suffix(
                                  f"{sha_tag}-cpu", suffix=suffix
                              )
                              in tag_mapping[old_tag]
                          )
                      else:
                          raise RuntimeError(
                              f"Invalid image name: {image_name}"
                          )
  
                  elif ML_CUDA_VERSION in old_tag:
                      assert (
                          _with_suffix("nightly-gpu", suffix=suffix)
                          in tag_mapping[old_tag]
                      )
                      if "-deps" in image_name:
                          assert (
                              _with_suffix(
                                  f"{date_tag}-gpu", suffix=suffix
                              )
                              in tag_mapping[old_tag]
                          )
                      elif image_name == "ray":
                          assert (
                              _with_suffix(
                                  f"{sha_tag}-gpu", suffix=suffix
                              )
                              in tag_mapping[old_tag]
                          )
                      # For ray-ml, nightly should refer to the GPU image.
                      elif image_name == "ray-ml":
                          assert (
                              _with_suffix("nightly", suffix=suffix)
                              in tag_mapping[old_tag]
                          )
                          assert (
                              _with_suffix(f"{sha_tag}", suffix=suffix)
                              in tag_mapping[old_tag]
                          )
                          assert (
                              _with_suffix(
                                  f"{sha_tag}-gpu", suffix=suffix
                              )
                              in tag_mapping[old_tag]
                          )
                      else:
                          raise RuntimeError(
                              f"Invalid image name: {image_name}"
                          )
  
          # Tag and push all images.
          for old_tag in tag_mapping.keys():
              for new_tag in tag_mapping[old_tag]:
                  _tag_and_push(
                      full_image_name,
                      old_tag=old_tag,
                      new_tag=new_tag,
                      merge_build=merge_build,
                      release_pr_build=release_pr_build,
                  )
  
imports: import datetime
  import io
  import json
  import functools
  import glob
  import itertools
  import os
  import platform
  import shutil
  import subprocess
  import sys
  import tarfile
  from collections import defaultdict
  from pathlib import Path
  from typing import List, Optional, Tuple, Dict
  import click
  import docker
label_desc: Use image node_id 26 for calling a global function with example usage: push_and_tag_images(py_versions, image_types, merge_build, release_pr_build, image_list, suffix) without return types