function unsqueeze (array, dims, outer, size) {
  const s = size || arraySize(array)

  // unsqueeze outer dimensions
  if (outer) {
    for (let i = 0; i < outer; i++) {
      array = [array]
      s.unshift(1)
    }
  }

  // unsqueeze inner dimensions
  array = _unsqueeze(array, dims, 0)
  while (s.length < dims) {
    s.push(1)
  }

  return array
}
Unsqueeze a multi dimensional array: add dimensions when missing

Parameter `size` will be mutated to match the new, unsqueezed matrix size.

@param {Array} array
@param {number} dims       Desired number of dimensions of the array
@param {number} [outer]    Number of outer dimensions to be added
@param {Array} [size] Current size of array.
@returns {Array} returns the array itself
@private