# Path: t5x/gin_utils.py
# def parse_gin_flags(gin_search_paths: Sequence[str],
#                     gin_files: Sequence[str],
#                     gin_bindings: Sequence[str],
#                     skip_unknown: bool = False,
#                     finalize_config: bool = True):
# def rewrite_gin_args(args: Sequence[str]) -> Sequence[str]:
#   def _rewrite_gin_arg(arg):
# def summarize_gin_config(model_dir: str,
#                          summary_writer: Optional[metric_writers.MetricWriter],
#                          step: int):
# def run(main):
# def sum_fn(var1=gin.REQUIRED, var2=gin.REQUIRED):
# def bool_fn(var1=gin.REQUIRED):


from absl.testing import absltest
from t5x import gin_utils
        '--gin_file=path/to/file',
        'gin.value=3',
        '--gin.value=3',
        '--gin.value="3"',
        '--gin.value=\'3\'',
        '--gin.tricky="key = value"',
        '--gin.dict={"foo": 4, "bar": "four"}',
        '--gin.gin=bar',
        '--gin.scope/foo=bar',
    ]
    expected_args = [
        '--gin_file=path/to/file',
        'gin.value=3',
        '--gin_bindings=value = 3',
        '--gin_bindings=value = "3"',
        '--gin_bindings=value = \'3\'',
        '--gin_bindings=tricky = "key = value"',
        '--gin_bindings=dict = {"foo": 4, "bar": "four"}',
        '--gin_bindings=gin = bar',
        '--gin_bindings=scope/foo = bar',
    ]
    self.assertSequenceEqual(
        gin_utils.rewrite_gin_args(test_args), expected_args)

  def test_rewrite_gin_args_malformed(self):
    test_args = ['--gin.value=3', '--gin.test']
    with self.assertRaisesWithLiteralMatch(
        ValueError,
        "Gin bindings must be of the form '--gin.<param>=<value>', got: "
        '--gin.test'):

# Path: t5x/gin_utils.py
# def parse_gin_flags(gin_search_paths: Sequence[str],
#                     gin_files: Sequence[str],
#                     gin_bindings: Sequence[str],
#                     skip_unknown: bool = False,
#                     finalize_config: bool = True):
# def rewrite_gin_args(args: Sequence[str]) -> Sequence[str]:
#   def _rewrite_gin_arg(arg):
# def summarize_gin_config(model_dir: str,
#                          summary_writer: Optional[metric_writers.MetricWriter],
#                          step: int):
# def run(main):
# def sum_fn(var1=gin.REQUIRED, var2=gin.REQUIRED):
# def bool_fn(var1=gin.REQUIRED):


# Path: t5x/gin_utils_test.py
from absl.testing import absltest
from t5x import gin_utils

        '--gin_file=path/to/file',
        'gin.value=3',
        '--gin.value=3',
        '--gin.value="3"',
        '--gin.value=\'3\'',
        '--gin.tricky="key = value"',
        '--gin.dict={"foo": 4, "bar": "four"}',
        '--gin.gin=bar',
        '--gin.scope/foo=bar',
    ]
    expected_args = [
        '--gin_file=path/to/file',
        'gin.value=3',
        '--gin_bindings=value = 3',
        '--gin_bindings=value = "3"',
        '--gin_bindings=value = \'3\'',
        '--gin_bindings=tricky = "key = value"',
        '--gin_bindings=dict = {"foo": 4, "bar": "four"}',
        '--gin_bindings=gin = bar',
        '--gin_bindings=scope/foo = bar',
    ]
    self.assertSequenceEqual(
        gin_utils.rewrite_gin_args(test_args), expected_args)

  def test_rewrite_gin_args_malformed(self):
    test_args = ['--gin.value=3', '--gin.test']
    with self.assertRaisesWithLiteralMatch(
        ValueError,
        "Gin bindings must be of the form '--gin.<param>=<value>', got: "
        '--gin.test'):

      gin_utils.rewrite_gin_args(test_args)