Codec will be negociated and same codec on both directions is determined normally by TGW.
Payload sizes normally are determined by the codec preferrence defined on each gateway.
And different payload sizes can interoperate, i.e, g723ar53 on one direction, g723ar63 on the other.