1def normalize_rows(x: numpy.ndarray):
2 """
3 function that normalizes each row of the matrix x to have unit length.
4
5 Args:
6 ``x``: A numpy matrix of shape (n, m)
7
8 Returns:
9 ``x``: The normalized (by row) numpy matrix.
10 """
11 return x/numpy.linalg.norm(x, ord=2, axis=1, keepdims=True)
12