code: def download_and_verify_bazel():
      """Downloads a bazel binary from Github, verifying its SHA256 hash."""
      package = bazel_packages.get(
          (platform.system(), platform.machine())
      )
      if package is None:
          return None
  
      if not os.access(package.file, os.X_OK):
          uri = (package.base_uri or BAZEL_BASE_URI) + package.file
          sys.stdout.write(f"Downloading bazel from: {uri}\n")
  
          def progress(block_count, block_size, total_size):
              if total_size <= 0:
                  total_size = 170**6
              progress = (block_count * block_size) / total_size
              num_chars = 40
              progress_chars = int(num_chars * progress)
              sys.stdout.write(
                  "{} [{}{}] {}%\r".format(
                      package.file,
                      "#" * progress_chars,
                      "." * (num_chars - progress_chars),
                      int(progress * 100.0),
                  )
              )
  
          tmp_path, _ = urllib.request.urlretrieve(
              uri, None, progress if sys.stdout.isatty() else None
          )
          sys.stdout.write("\n")
  
          # Verify that the downloaded Bazel binary has the expected SHA256.
          with open(tmp_path, "rb") as downloaded_file:
              contents = downloaded_file.read()
  
          digest = hashlib.sha256(contents).hexdigest()
          if digest != package.sha256:
              print(
                  "Checksum mismatch for downloaded bazel binary (expected {}; got {}).".format(
                      package.sha256, digest
                  )
              )
              sys.exit(-1)
  
          # Write the file as the bazel file name.
          with open(package.file, "wb") as out_file:
              out_file.write(contents)
  
          # Mark the file as executable.
          st = os.stat(package.file)
          os.chmod(
              package.file,
              st.st_mode | stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH,
          )
  
      return os.path.join(".", package.file)
  
imports: import argparse
  import collections
  import hashlib
  import os
  import platform
  import re
  import shutil
  import stat
  import subprocess
  import sys
  import textwrap
  import urllib.request
  import logging
label_desc: Use image node_id 9 for calling a global function with example usage: download_and_verify_bazel() and returns: os, None