### Group action in sage

I want to define a group action in sage. The group is a direct product of two general linear groups. The set under action is of matrices and the action is $(A,B) (M)=A^{-1}BM$. Assume all matrices have compatible sizes in order for multiplication.
I might need a stabelizer later so I was thinking doing it in GAP but could not figure out how. Any suggestions?