So is it if-else condition first followed by for loop like
if multi_input : # 1 Extra Dimension then expected number of dimensions, here (13 , 12) ---> 13 is extra
# iterate over the list and caluclate the matmul for every value and append in the output list
else : # simply calculate the matmul
Also, the remaining explanation should help, I include it for easy of access:
If both tensors are 1-dimensional, the dot product (scalar) is returned.
If both arguments are 2-dimensional, the matrix-matrix product is returned.
If the first argument is 1-dimensional and the second argument is 2-dimensional, a 1 is prepended to its dimension for the purpose of the matrix multiply. After the matrix multiply, the prepended dimension is removed.