code: public SDVariable reductionBroadcastableWithOrigShape(int origRank, int[] reduceDims, SDVariable toExpand) {
          if (Shape.isWholeArray(origRank, reduceDims)) {
              //Output is [1,1] which is already broadcastable
              return toExpand;
          } else if (origRank == 2 && reduceDims.length == 1) {
              //In this case: [a,b] -> [1,b] or [a,b] -> [a,1]
              //both are already broadcastable
              return toExpand;
          } else {
              //Example: [a,b,c].sum(1) -> [a,c]... want [a,1,c]
              for (int d : reduceDims) {
                  toExpand = sameDiff().expandDims(toExpand, d);
              }
              return toExpand;
          }
      }
docs: Add 1s as required to the array make an array possible to be broadcast with the original (pre-reduce) array.
  <p>
  Example: if doing [a,b,c].sum(1), result is [a,c]. To 'undo' this in a way that can be auto-broadcast,
  we want to expand as required - i.e., [a,c] -> [a,1,c] which can be auto-broadcast with the original [a,b,c].
  This is typically only used with reduction operations backprop.
  
  @param origRank   Rank of the original array, before the reduction was executed
  @param reduceDims Dimensions that the original array was reduced from
  @param toExpand   Array to add 1s to the shape to (such that it can be
  @return Reshaped array.