Impelementation of Approch?

Can you help me to find the sum of all submatrices Explination

Hey, what is that you want help with. The post isn’t very clear.