code: def check_or_create_intermediate_results_dir(
      intermediate_results_dir: Optional[str],
  ) -> str:
      """Checks or creates the path to the directory for intermediate results."""
      if intermediate_results_dir is None:
          intermediate_results_dir = tempfile.mkdtemp()
      if not os.path.isdir(intermediate_results_dir):
          logging.info(
              "Creating a directory for intermediate results in %s",
              intermediate_results_dir,
          )
          os.makedirs(intermediate_results_dir)
      else:
          logging.info(
              "Re-using the directory for intermediate results in %s",
              intermediate_results_dir,
          )
      return intermediate_results_dir
  
imports: import os
  import subprocess
  import sys
  import tempfile
  from typing import Any, Dict, Optional, Tuple
  from absl import app
  from absl import flags
  from absl import logging
  import tensorflow
label_desc: Use image node_id 12 for calling a global function with example usage: check_or_create_intermediate_results_dir(intermediate_results_dir) and returns: intermediate_results_dir