[WIP] Add r set cardinality

This will add `r_set_cardinality` functionality with tests for each layer.