code: def create_all_commands_and_logfiles(
      intermediate_results_dir: str, used_in_test: bool = False
  ):
      """Creates 3 (command, logfile) to be executed later."""
      if not used_in_test:
          check_flags()
      commands = []
      # make_examples_somatic
      nonvariant_site_tfrecord_path = None
      if _OUTPUT_GVCF.value is not None:
          nonvariant_site_tfrecord_path = os.path.join(
              intermediate_results_dir,
              "gvcf.tfrecord@{}.gz".format(_NUM_SHARDS.value),
          )
  
      examples = os.path.join(
          intermediate_results_dir,
          "make_examples_somatic.tfrecord@{}.gz".format(
              _NUM_SHARDS.value
          ),
      )
  
      if _LOGGING_DIR.value and _RUNTIME_REPORT.value:
          runtime_directory = os.path.join(
              _LOGGING_DIR.value, "make_examples_runtime_by_region"
          )
          if not os.path.isdir(runtime_directory):
              logging.info(
                  "Creating a make_examples_somatic runtime by region directory in %s",
                  runtime_directory,
              )
              os.makedirs(runtime_directory)
          # The path to runtime metrics output is sharded just like the examples.
          runtime_by_region_path = os.path.join(
              runtime_directory,
              "make_examples_runtime@{}.tsv".format(_NUM_SHARDS.value),
          )
      else:
          runtime_by_region_path = None
  
      commands.append(
          make_examples_somatic_command(
              ref=_REF.value,
              reads_tumor=_READS_TUMOR.value,
              reads_normal=_READS_NORMAL.value,
              examples=examples,
              runtime_by_region_path=runtime_by_region_path,
              extra_args=_MAKE_EXAMPLES_EXTRA_ARGS.value,
              # kwargs:
              gvcf=nonvariant_site_tfrecord_path,
              regions=_REGIONS.value,
              sample_name_tumor=_SAMPLE_NAME_TUMOR.value,
              sample_name_normal=_SAMPLE_NAME_NORMAL.value,
          )
      )
  
      # call_variants
      call_variants_output = os.path.join(
          intermediate_results_dir, "call_variants_output.tfrecord.gz"
      )
      model_ckpt = get_model_ckpt(
          _MODEL_TYPE.value, _CUSTOMIZED_MODEL.value
      )
      commands.append(
          call_variants_command(
              outfile=call_variants_output,
              examples=examples,
              model_ckpt=model_ckpt,
              extra_args=_CALL_VARIANTS_EXTRA_ARGS.value,
              use_slim_model=_USE_SLIM_MODEL.value,
          )
      )
  
      # postprocess_variants
      commands.append(
          postprocess_variants_command(
              ref=_REF.value,
              infile=call_variants_output,
              outfile=_OUTPUT_VCF.value,
              process_somatic=_PROCESS_SOMATIC.value,
              extra_args=_POSTPROCESS_VARIANTS_EXTRA_ARGS.value,
              nonvariant_site_tfrecord_path=nonvariant_site_tfrecord_path,
              gvcf_outfile=_OUTPUT_GVCF.value,
          )
      )
  
      # vcf_stats_report
      if _VCF_STATS_REPORT.value:
          commands.append(
              vcf_stats_report_command(
                  vcf_path=_OUTPUT_VCF.value, title=_REPORT_TITLE.value
              )
          )
  
      # runtime-by-region
      if _LOGGING_DIR.value and _RUNTIME_REPORT.value:
          commands.append(
              runtime_by_region_vis_command(
                  runtime_by_region_path, title=_REPORT_TITLE.value
              )
          )
  
      return commands
  
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 15 for calling a global function with example usage: create_all_commands_and_logfiles(intermediate_results_dir, used_in_test) and returns: commands