# Path: tensorflow_model_remediation/min_diff/keras/utils/structure_utils.py
# def _flatten_min_diff_structure(struct, run_validation=False):
# def _pack_min_diff_sequence_as(struct, flat_sequence):
# def _assert_same_min_diff_structure(struct1, struct2):
#   def _err_msg(specifics_template, use_dict_keys=False):
# def _is_min_diff_element(element, element_type=None):
# def validate_min_diff_structure(struct,
#                                 struct_name="struct",
#                                 element_type=None):


import tensorflow as tf
from tensorflow_model_remediation.min_diff.keras.utils import structure_utils
        r"structure is a sequence.*list.*0.*\[\]"):
      _ = structure_utils._pack_min_diff_sequence_as(struct, short_seq)

    long_seq = [1, 2]
    with self.assertRaisesRegex(
        ValueError, "structure is of type.*str(.|\n)*"
        r"structure is a sequence.*list.*2.*\[1, 2\]"):
      _ = structure_utils._pack_min_diff_sequence_as(struct, long_seq)

  def testPackAsDict(self):
    struct = {"k1": "elem", "k2": "elem"}
    seq = [1, 2]
    res = structure_utils._pack_min_diff_sequence_as(struct, seq)
    self.assertDictEqual(res, {"k1": 1, "k2": 2})
    # Passing in the reversed sequence should result in the key values be
    # swapped.
    res = structure_utils._pack_min_diff_sequence_as(struct,
                                                     list(reversed(seq)))
    self.assertDictEqual(res, {"k1": 2, "k2": 1})

    short_seq = [1]
    with self.assertRaisesRegex(
        ValueError, "Dict had 2 keys.*flat_sequence "
        r"had 1 element\(s\).*(k[12].*){2}.*\[1\]"):
      _ = structure_utils._pack_min_diff_sequence_as(struct, short_seq)

    long_seq = [1, 2, 3]
    with self.assertRaisesRegex(
        ValueError, "Dict had 2 keys.*flat_sequence had"
        r" 3 element\(s\).*(k[12].*){2}.*\[1, 2, 3\]"):

# Path: tensorflow_model_remediation/min_diff/keras/utils/structure_utils.py
# def _flatten_min_diff_structure(struct, run_validation=False):
# def _pack_min_diff_sequence_as(struct, flat_sequence):
# def _assert_same_min_diff_structure(struct1, struct2):
#   def _err_msg(specifics_template, use_dict_keys=False):
# def _is_min_diff_element(element, element_type=None):
# def validate_min_diff_structure(struct,
#                                 struct_name="struct",
#                                 element_type=None):


# Path: tensorflow_model_remediation/min_diff/keras/utils/structure_utils_test.py
import tensorflow as tf
from tensorflow_model_remediation.min_diff.keras.utils import structure_utils

        r"structure is a sequence.*list.*0.*\[\]"):
      _ = structure_utils._pack_min_diff_sequence_as(struct, short_seq)

    long_seq = [1, 2]
    with self.assertRaisesRegex(
        ValueError, "structure is of type.*str(.|\n)*"
        r"structure is a sequence.*list.*2.*\[1, 2\]"):
      _ = structure_utils._pack_min_diff_sequence_as(struct, long_seq)

  def testPackAsDict(self):
    struct = {"k1": "elem", "k2": "elem"}
    seq = [1, 2]
    res = structure_utils._pack_min_diff_sequence_as(struct, seq)
    self.assertDictEqual(res, {"k1": 1, "k2": 2})
    # Passing in the reversed sequence should result in the key values be
    # swapped.
    res = structure_utils._pack_min_diff_sequence_as(struct,
                                                     list(reversed(seq)))
    self.assertDictEqual(res, {"k1": 2, "k2": 1})

    short_seq = [1]
    with self.assertRaisesRegex(
        ValueError, "Dict had 2 keys.*flat_sequence "
        r"had 1 element\(s\).*(k[12].*){2}.*\[1\]"):
      _ = structure_utils._pack_min_diff_sequence_as(struct, short_seq)

    long_seq = [1, 2, 3]
    with self.assertRaisesRegex(
        ValueError, "Dict had 2 keys.*flat_sequence had"
        r" 3 element\(s\).*(k[12].*){2}.*\[1, 2, 3\]"):

      _ = structure_utils._pack_min_diff_sequence_as(struct, long_seq)