code: def build_or_pull_base_images(
      py_versions: List[str],
      image_types: List[str],
      rebuild_base_images: bool = True,
      suffix: Optional[str] = None,
  ) -> bool:
      """Returns images to tag and build."""
      repositories = [
          f"{DOCKER_HUB_REPO}/base-deps",
          f"{DOCKER_HUB_REPO}/ray-deps",
      ]
      tags = [
          f"nightly-{py_version}-{image_type}"
          for py_version, image_type in itertools.product(
              py_versions, image_types
          )
      ]
  
      try:
          is_stale = check_staleness(repositories[0], tags[0])
  
          # We still pull even if we have to rebuild the base images to help with
          # caching.
          for repository in repositories:
              for tag in tags:
                  DOCKER_CLIENT.api.pull(repository=repository, tag=tag)
      except Exception as e:
          print(e)
          is_stale = True
  
      if rebuild_base_images or _release_build() or is_stale:
          build_base_images(py_versions, image_types, suffix=suffix)
          return True
      else:
          print("Just pulling images!")
          return False
  
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 18 for calling a global function with example usage: build_or_pull_base_images(py_versions, image_types, rebuild_base_images, suffix) and returns: True, False