### Question:
NormalizeRows extends SingleParentVariable<Matrix> { @Override public Matrix apply(ComputationContext ctx) { double[] parentData = ctx.data(parent()).data(); int rows = this.rows; int cols = this.cols; double[] result = new double[rows * cols]; for (int row = 0; row < rows; row++) { double sum = 0; for (int col = 0; col < cols; col++) { int elementIndex = row * cols + col; sum += Math.pow(parentData[elementIndex], 2); } double l2 = Math.sqrt(sum); for (int col = 0; col < cols; col++) { int elementIndex = row * cols + col; result[elementIndex] = parentData[elementIndex] / l2; } } return new Matrix(result, this.rows, this.cols); } NormalizeRows(Variable<Matrix> matrix); @Override Matrix apply(ComputationContext ctx); @Override Matrix gradient(Variable<?> parent, ComputationContext ctx);  }### Answer:
@Test void testApply() { double[] data = new double[]{ 3, 4, 1, 0, 0, 1 }; double[] expectedData = new double[]{ 3.0/5, 4.0/5, 1, 0, 0, 1 }; Weights<Matrix> w = new Weights<>(new Matrix(data, 3, 2)); Variable<Matrix> normalizeRows = new NormalizeRows(w); assertArrayEquals(expectedData, ctx.forward(normalizeRows).data()); }