Zoox's onboard perception and planning computations use matrix multiplication for feature transformations. Implement matrix multiplication with a cache-conscious access pattern rather than the straightforward triple loop.
Given matrix A with dimensions m x n and matrix B with dimensions n x p, return their product C = A * B, with dimensions m x p. Your implementation must use both matrix blocking and a transposed representation of B so that repeated inner-loop accesses are contiguous in memory.
The block size is provided as an argument. Blocks at the matrix boundaries may be smaller than the requested block size.
Implement cache_optimized_multiply(A, B, block_size):
A is a non-empty list of m rows, each containing n integers.B is a non-empty list of n rows, each containing p integers.block_size is a positive integer.m rows, each containing p integers, where C[i][j] = sum(A[i][k] * B[k][j] for k in range(n)).def cache_optimized_multiply(A, B, block_size):