code: def system_specific_test_config(environ_cp):
      """Add default build and test flags required for TF tests to bazelrc."""
      write_to_bazelrc("test --flaky_test_attempts=3")
      write_to_bazelrc("test --test_size_filters=small,medium")
  
      # Each instance of --test_tag_filters or --build_tag_filters overrides all
      # previous instances, so we need to build up a complete list and write a
      # single list of filters for the .bazelrc file.
  
      # Filters to use with both --test_tag_filters and --build_tag_filters
      test_and_build_filters = [
          "-benchmark-test",
          "-no_oss",
          "-oss_excluded",
      ]
      # Additional filters for --test_tag_filters beyond those in
      # test_and_build_filters
      test_only_filters = ["-oss_serial"]
      if is_windows():
          test_and_build_filters += ["-no_windows", "-windows_excluded"]
          if (environ_cp.get("TF_NEED_CUDA", None) == "1") or (
              environ_cp.get("TF_NEED_ROCM", None) == "1"
          ):
              test_and_build_filters += ["-no_windows_gpu", "-no_gpu"]
          else:
              test_and_build_filters.append("-gpu")
      elif is_macos():
          test_and_build_filters += [
              "-gpu",
              "-nomac",
              "-no_mac",
              "-mac_excluded",
          ]
      elif is_linux():
          if (environ_cp.get("TF_NEED_CUDA", None) == "1") or (
              environ_cp.get("TF_NEED_ROCM", None) == "1"
          ):
              test_and_build_filters.append("-no_gpu")
              write_to_bazelrc("test --test_env=LD_LIBRARY_PATH")
          else:
              test_and_build_filters.append("-gpu")
          if environ_cp.get("TF_NEED_ROCM", None) == "1":
              test_and_build_filters.append("-no_rocm")
  
      write_to_bazelrc(
          "test --test_tag_filters=%s"
          % ",".join(test_and_build_filters + test_only_filters)
      )
      write_to_bazelrc(
          "test --build_tag_filters=%s"
          % ",".join(test_and_build_filters)
      )
      write_to_bazelrc(
          "build --test_tag_filters=%s"
          % ",".join(test_and_build_filters + test_only_filters)
      )
      write_to_bazelrc(
          "build --build_tag_filters=%s"
          % ",".join(test_and_build_filters)
      )
  
      # Disable tests with "v1only" tag in "v2" Bazel config, but not in "v1" config
      write_to_bazelrc(
          "test:v1 --test_tag_filters=%s"
          % ",".join(test_and_build_filters + test_only_filters)
      )
      write_to_bazelrc(
          "test:v1 --build_tag_filters=%s"
          % ",".join(test_and_build_filters)
      )
      write_to_bazelrc(
          "test:v2 --test_tag_filters=%s"
          % ",".join(
              test_and_build_filters + test_only_filters + ["-v1only"]
          )
      )
      write_to_bazelrc(
          "test:v2 --build_tag_filters=%s"
          % ",".join(test_and_build_filters + ["-v1only"])
      )
  
imports: import argparse
  import os
  import pathlib
  import platform
  import re
  import subprocess
  import sys
label_desc: Use image node_id 33 for calling a global function with example usage: system_specific_test_config(environ_cp) without return types