Transformer not able to do bracket matching

I have been trying to apply transformers to classify simpler sequences. One such example is in my earlier post with working code:

However, the code does not work for the following bracket matching examples. I was told that matching brackets is quite a tricky problem for transformers as it has high circuit complexity. But if someone wants to take a crack at it. Or try it for any other simpler sequences.

Bracket matching examples.
([‘()()()()()’, ‘()()))()()’, ‘())()())()’, ‘(((())))))’, ‘()()))()()’],
[1, 0, 0, 0, 0])