()
return ParentClass, has_keras
Try to import keras from keras and tensorflow.

    This is possible to import the sequence from keras or tensorflow.
Try to import keras from keras and tensorflow.
Try to import keras from keras and tensorflow .
def import_keras():
    """Try to import keras from keras and tensorflow.

    This is possible to import the sequence from keras or tensorflow.
    """

    def import_from_keras():
        try:
            import keras  # noqa

            if hasattr(keras.utils, "Sequence"):
                return (keras.utils.Sequence,), True
            else:
                return (keras.utils.data_utils.Sequence,), True
        except ImportError:
            return tuple(), False

    def import_from_tensforflow():
        try:
            from tensorflow import keras

            if hasattr(keras.utils, "Sequence"):
                return (keras.utils.Sequence,), True
            else:
                return (keras.utils.data_utils.Sequence,), True
        except ImportError:
            return tuple(), False

    ParentClassKeras, has_keras_k = import_from_keras()
    ParentClassTensorflow, has_keras_tf = import_from_tensforflow()
    has_keras = has_keras_k or has_keras_tf
    if has_keras:
        if has_keras_k:
            ParentClass = ParentClassKeras
        else:
            ParentClass = ParentClassTensorflow
    else:
        ParentClass = (object,)
    return ParentClass, has_keras
def import_keras ( ) : def import_from_keras ( ) : try : import keras # noqa if hasattr ( keras . utils , "Sequence" ) : return ( keras . utils . Sequence , ) , True else : return ( keras . utils . data_utils . Sequence , ) , True except ImportError : return tuple ( ) , False def import_from_tensforflow ( ) : try : from tensorflow import keras if hasattr ( keras . utils , "Sequence" ) : return ( keras . utils . Sequence , ) , True else : return ( keras . utils . data_utils . Sequence , ) , True except ImportError : return tuple ( ) , False ParentClassKeras , has_keras_k = import_from_keras ( ) ParentClassTensorflow , has_keras_tf = import_from_tensforflow ( ) has_keras = has_keras_k or has_keras_tf if has_keras : if has_keras_k : ParentClass = ParentClassKeras else : ParentClass = ParentClassTensorflow else : ParentClass = ( object , ) return ParentClass , has_keras