def _like_rnncell_(cell):
    """Checks that a given object is an RNNCell by using duck typing."""

    conditions = [hasattr(cell, "output_size"), hasattr(cell, "state_size"),

                  hasattr(cell, "zero_state"), callable(cell)]

    return all(conditions)
Checks that a given object is an RNNCell by using duck typing.
deepctr/contrib/rnn.py