### Question:
INDArrayHelper { public static INDArray forceCorrectShape(INDArray source) { return source.shape()[0] == 1 && source.rank() > 1 ? source : Nd4j.expandDims(source, 0); }  static INDArray forceCorrectShape(INDArray source); static INDArray createBatchForShape(long batchSize, long... shape); static INDArray createRnnBatchForShape(long batchSize, long... shape);  }### Answer:
@Test public void when_inputHasIncorrectShape_expect_outputWithCorrectShape() { INDArray input = Nd4j.create(new double[] { 1.0, 2.0, 3.0}); INDArray output = INDArrayHelper.forceCorrectShape(input); assertEquals(2, output.shape().length); assertEquals(1, output.shape()[0]); assertEquals(3, output.shape()[1]); }
@Test public void when_inputHasCorrectShape_expect_outputWithSameShape() { INDArray input = Nd4j.create(new double[] { 1.0, 2.0, 3.0}).reshape(1, 3); INDArray output = INDArrayHelper.forceCorrectShape(input); assertEquals(2, output.shape().length); assertEquals(1, output.shape()[0]); assertEquals(3, output.shape()[1]); }
@Test public void when_inputHasOneDimension_expect_outputWithTwoDimensions() { INDArray input = Nd4j.create(new double[] { 1.0 }); INDArray output = INDArrayHelper.forceCorrectShape(input); assertEquals(2, output.shape().length); assertEquals(1, output.shape()[0]); assertEquals(1, output.shape()[1]); }