in tensorflow_model_remediation/min_diff/keras/utils/structure_utils.py [0:0]
def _is_min_diff_element(element, element_type=None):
"""Returns `True` if `element` is a MinDiff element and `False` otherwise."""
if element_type is not None:
if not isinstance(element_type, type):
raise TypeError(
"`element_type` should be a class corresponding to expected type. "
"Instead an object instance was given: {}".format(element_type))
# Return False if element is of the wrong type (if indicated).
if not isinstance(element, element_type):
return False
is_single_element = not tf.nest.is_nested(element)
is_tuple = isinstance(element, tuple)
return is_single_element or is_tuple