code: def normalise_rows(matrix):
      
  
      lengths = np.apply_along_axis(np.linalg.norm, 1, matrix)
      if not (lengths > 0).all():
          # raise ValueError('Cannot normalise 0 length vector to length 1')
          # print(matrix)
          lengths[lengths == 0] = 1
      return matrix / lengths[:, np.newaxis]
docs: Scales all rows to length 1. Fails when row is 0-length, so it
      leaves these unchanged