Rank of a tensor and quantum entanglement