function checkBroadcastingRules (size, toSize) {
  const N = toSize.length
  const dim = size.length
  for (let j = 0; j < dim; j++) {
    const n = N - dim + j
    if ((size[j] < toSize[n] && size[j] > 1) || (size[j] > toSize[n])) {
      throw new Error(
        `shape mismatch: mismatch is found in arg with shape (${size}) not possible to broadcast dimension ${dim} with size ${size[j]} to size ${toSize[n]}`
      )
    }
  }
}
Checks if it's possible to broadcast a size to another size
@param {number[]} size The size of the array to check
@param {number[]} toSize The size of the array to validate if it can be broadcasted to