Optimized calculation of transformation matrix R

Hi, Are there any optimizations that we need to consider ? Currently when running " Calculate transformation matrix R" UNQ_C7 it takes more than 5-6 minutes. I am using a naïve equivalence formula (X^T(XR - Y) * 2/m ) in gradient descent.
Something similar to
np.dot(…np.dot()) * …

I believe that cell is expected to take some time to run.