code: def convert_tests_for_flatbuffers(
      tests: List[TestData],
      to_flatbuff: Path,
      working_dir: Path,
      color_enum: Type[Union[Color, NoColor]],
  ):
      working_dir.mkdir(parents=True, exist_ok=True)
      for test in tests:
          if test.is_shell:
              test.skip = True
              test.skip_reason = (
                  "Cannot convert bash based tests to flatbuffers"
              )
              continue
          if "flatbuffer" in test.command_line:
              test.skip = True
              test.skip_reason = "already a flatbuffer test"
              continue
          if "malformed" in test.command_line:
              test.skip = True
              test.skip_reason = "malformed input"
              continue
          if len(test.input_files) < 1:
              test.skip = True
              test.skip_reason = "no input files for for automatic converted flatbuffer test"
              continue
          if "dictionary" in test.command_line:
              test.skip = True
              test.skip_reason = "currently dictionaries are not supported for automatic converted flatbuffer tests"
              continue
          if "help" in test.command_line:
              test.skip = True
              test.skip_reason = "--help test skipped for automatic converted flatbuffer tests"
              continue
          # todo: 300 understand why is it failing
          # test 189, 312, 316, 318, 319, 351, 367, 368, 394, 438, 456, 457 depend on dsjson parser behaviour
          # they can be enabled if we ignore diffing the --extra_metrics
          # (324-326) deals with corrupted data, so cannot be translated to fb
          # pdrop is not supported in fb, so 327-331 are excluded
          # 336, 337, 338, 442, 444, 450, 452 - the FB converter script seems to be affecting the invert_hash
          # 423, 424, 425, 426 - FB converter removes feature names from invert_hash (probably the same issue as above)
          if str(test.id) in (
              "300",
              "189",
              "312",
              "316",
              "318",
              "319",
              "324",
              "325",
              "326",
              "327",
              "328",
              "329",
              "330",
              "331",
              "336",
              "337",
              "338",
              "351",
              "367",
              "368",
              "394",
              "399",
              "400",
              "404",
              "405",
              "406",
              "407",
              "411",
              "415",
              "426",
              "428",
              "438",
              "442",
              "444",
              "450",
              "452",
              "456",
              "457",
              "458",
              "459",
              "460",
              "461",
              "462",
          ):
              test.skip = True
              test.skip_reason = "test skipped for automatic converted flatbuffer tests for unknown reason"
              continue
  
          # test id is being used as an index here, not necessarily a contract
          depends_on_test = (
              get_test(test.depends_on[0], tests)
              if len(test.depends_on) > 0
              else None
          )
  
          fb_test_converter = fb_converter.FlatbufferTest(
              test, working_dir, depends_on_test=depends_on_test
          )
          fb_test_converter.to_flatbuffer(to_flatbuff, color_enum)
  
      return tests
  
imports: import shutil
  import threading
  import argparse
  import difflib
  from pathlib import Path
  import re
  import os
  import subprocess
  import sys
  import traceback
  import shlex
  import math
  import json
  from concurrent.futures import ThreadPoolExecutor, Future
  from enum import Enum
  import socket
  from typing import Any, Callable, Dict, List, Mapping, Optional, Set, Tuple, Type, Union, cast
  from run_tests_common import TestData
  import runtests_flatbuffer_converter
label_desc: Use image node_id 21 for calling a global function with example usage: convert_tests_for_flatbuffers(tests, to_flatbuff, working_dir, color_enum) and returns: tests