It may be helpful to rename `tensor` to something that is not a class name in cp-als. (And other functions, if they are doing the same thing.)