# 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 collections
import tensorflow as tf
from tensorflow_model_remediation.min_diff.keras.utils import structure_utils
  sensitive_dataset_present = sensitive_group_dataset is not None
  nonsensitive_dataset_present = nonsensitive_group_dataset is not None
  # Case where min_diff_dataset is set and the others are not.
  set_to_use_min_diff_dataset = (
      min_diff_dataset_present and
      not (sensitive_dataset_present or nonsensitive_dataset_present))
  # Case where sensitive_group_dataset and nonsensitive_group_dataset are both
  # set and min_diff_dataset is not.
  set_to_construct_min_diff_dataset = ((sensitive_dataset_present and
                                        nonsensitive_dataset_present) and
                                       not min_diff_dataset_present)
  if not (set_to_use_min_diff_dataset or set_to_construct_min_diff_dataset):
    raise ValueError(
        "Invalid arguments: You must either pass in only the `min_diff_dataset`"
        " (and leave `sensitive_group_dataset` and `nonsensitive_group_dataset`"
        " as None) or set both `sensitive_group_dataset` and "
        "`nonsensitive_group_dataset` (and leave `min_diff_dataset` as None), "
        "given: \n"
        "\n`sensitive_group_dataset`: {}"
        "\n`nonsensitive_group_dataset`: {}"
        "\n`min_diff_dataset`: {}".format(sensitive_group_dataset,
                                          nonsensitive_group_dataset,
                                          min_diff_dataset))

  # First construct the min_diff_dataset if need be.
  if set_to_construct_min_diff_dataset:
    min_diff_dataset = build_min_diff_dataset(sensitive_group_dataset,
                                              nonsensitive_group_dataset)
  else:
    # validate min_diff_dataset since it was passed in.

# 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/input_utils.py
import collections
import tensorflow as tf
from tensorflow_model_remediation.min_diff.keras.utils import structure_utils

  sensitive_dataset_present = sensitive_group_dataset is not None
  nonsensitive_dataset_present = nonsensitive_group_dataset is not None
  # Case where min_diff_dataset is set and the others are not.
  set_to_use_min_diff_dataset = (
      min_diff_dataset_present and
      not (sensitive_dataset_present or nonsensitive_dataset_present))
  # Case where sensitive_group_dataset and nonsensitive_group_dataset are both
  # set and min_diff_dataset is not.
  set_to_construct_min_diff_dataset = ((sensitive_dataset_present and
                                        nonsensitive_dataset_present) and
                                       not min_diff_dataset_present)
  if not (set_to_use_min_diff_dataset or set_to_construct_min_diff_dataset):
    raise ValueError(
        "Invalid arguments: You must either pass in only the `min_diff_dataset`"
        " (and leave `sensitive_group_dataset` and `nonsensitive_group_dataset`"
        " as None) or set both `sensitive_group_dataset` and "
        "`nonsensitive_group_dataset` (and leave `min_diff_dataset` as None), "
        "given: \n"
        "\n`sensitive_group_dataset`: {}"
        "\n`nonsensitive_group_dataset`: {}"
        "\n`min_diff_dataset`: {}".format(sensitive_group_dataset,
                                          nonsensitive_group_dataset,
                                          min_diff_dataset))

  # First construct the min_diff_dataset if need be.
  if set_to_construct_min_diff_dataset:
    min_diff_dataset = build_min_diff_dataset(sensitive_group_dataset,
                                              nonsensitive_group_dataset)
  else:
    # validate min_diff_dataset since it was passed in.

    structure_utils.validate_min_diff_structure(