code: def create_image_tags(
      image_name: str,
      py_versions: List[str],
      image_types: List[str],
      specific_tag: Optional[str] = None,
      version: str = "nightly",
      suffix: Optional[str] = None,
  ):
      # Mapping from old tags to new tags.
      # These are the tags we will push.
      # The key is the full image name, and the values are all the tags
      # for that image.
      tag_mapping = defaultdict(list)
      for py_name in py_versions:
          for image_type in image_types:
              if image_name == "ray-ml":
                  if image_type not in [
                      ML_CUDA_VERSION,
                      "cpu",
                  ]:
                      print(
                          "ML Docker image is not built for the following "
                          f"device type: {image_type}"
                      )
                      continue
                  if py_name not in ML_IMAGES_PY_VERSIONS:
                      print(
                          "ML Docker iamge is not build for the following "
                          f"python version: {py_name}"
                      )
                      continue
  
              tag = _with_suffix(
                  f"{version}-{py_name}-{image_type}", suffix=suffix
              )
  
              tag_mapping[tag].append(tag)
  
      # If no device is specified, it should map to CPU image.
      # For ray-ml image, if no device specified, it should map to GPU image.
      # "-gpu" tag should refer to the ML_CUDA_VERSION
      for old_tag in tag_mapping.keys():
          if "cpu" in old_tag and image_name != "ray-ml":
              new_tags = _create_new_tags(
                  tag_mapping[old_tag], old_str="-cpu", new_str=""
              )
              tag_mapping[old_tag].extend(new_tags)
          elif ML_CUDA_VERSION in old_tag:
              new_tags = _create_new_tags(
                  tag_mapping[old_tag],
                  old_str=f"-{ML_CUDA_VERSION}",
                  new_str="-gpu",
              )
              tag_mapping[old_tag].extend(new_tags)
  
              if image_name == "ray-ml":
                  new_tags = _create_new_tags(
                      tag_mapping[old_tag],
                      old_str=f"-{ML_CUDA_VERSION}",
                      new_str="",
                  )
                  tag_mapping[old_tag].extend(new_tags)
  
      # No Python version specified should refer to DEFAULT_PYTHON_VERSION
      for old_tag in tag_mapping.keys():
          if DEFAULT_PYTHON_VERSION in old_tag:
              new_tags = _create_new_tags(
                  tag_mapping[old_tag],
                  old_str=f"-{DEFAULT_PYTHON_VERSION}",
                  new_str="",
              )
              tag_mapping[old_tag].extend(new_tags)
  
      # For all tags, create Date/Sha tags
      if specific_tag:
          for old_tag in tag_mapping.keys():
              new_tags = _create_new_tags(
                  tag_mapping[old_tag],
                  old_str=version,
                  new_str=specific_tag,
              )
              tag_mapping[old_tag].extend(new_tags)
  
      return tag_mapping
  
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 25 for calling a global function with example usage: create_image_tags(image_name, py_versions, image_types, specific_tag, version, suffix) and returns: tag_mapping