function qr_(x, fullMatrices = false) {
    (0, _util.assert)(x.rank >= 2, ()=>`qr() requires input tensor to have a rank >= 2, but got rank ${x.rank}`);
    if (x.rank === 2) return qr2d(x, fullMatrices);
    else {
        // Rank > 2.
        // TODO(cais): Below we split the input into individual 2D tensors,
        //   perform QR decomposition on them and then stack the results back
        //   together. We should explore whether this can be parallelized.
        const outerDimsProd = x.shape.slice(0, x.shape.length - 2).reduce((value, prev)=>value * prev);
        const x2ds = (0, _unstack.unstack)((0, _reshape.reshape)(x, [
            outerDimsProd,
            x.shape[x.shape.length - 2],
            x.shape[x.shape.length - 1]
        ]), 0);
        const q2ds = [];
        const r2ds = [];
        x2ds.forEach((x2d)=>{
            const [q2d, r2d] = qr2d(x2d, fullMatrices);
            q2ds.push(q2d);
            r2ds.push(r2d);
        });
        const q = (0, _reshape.reshape)((0, _stack.stack)(q2ds, 0), x.shape);
        const r = (0, _reshape.reshape)((0, _stack.stack)(r2ds, 0), x.shape);
        return [
            q,
            r
        ];
    }
}
Compute QR decomposition of m-by-n matrix using Householder transformation.

Implementation based on
  [http://www.cs.cornell.edu/~bindel/class/cs6210-f09/lec18.pdf]
(http://www.cs.cornell.edu/~bindel/class/cs6210-f09/lec18.pdf)

```js
const a = tf.tensor2d([[1, 2], [3, 4]]);
let [q, r] = tf.linalg.qr(a);
console.log('Q');
q.print();
console.log('R');
r.print();
console.log('Orthogonalized');
q.dot(q.transpose()).print()  // should be nearly the identity matrix.
console.log('Reconstructed');
q.dot(r).print(); // should be nearly [[1, 2], [3, 4]];
```

@param x The `tf.Tensor` to be QR-decomposed. Must have rank >= 2. Suppose
  it has the shape `[..., M, N]`.
@param fullMatrices An optional boolean parameter. Defaults to `false`.
  If `true`, compute full-sized `Q`. If `false` (the default),
  compute only the leading N columns of `Q` and `R`.
@returns An `Array` of two `tf.Tensor`s: `[Q, R]`. `Q` is a unitary matrix,
  i.e., its columns all have unit norm and are mutually orthogonal.
  If `M >= N`,
    If `fullMatrices` is `false` (default),
      - `Q` has a shape of `[..., M, N]`,
      - `R` has a shape of `[..., N, N]`.
    If `fullMatrices` is `true` (default),
      - `Q` has a shape of `[..., M, M]`,
      - `R` has a shape of `[..., M, N]`.
  If `M < N`,
    - `Q` has a shape of `[..., M, M]`,
    - `R` has a shape of `[..., M, N]`.
@throws If the rank of `x` is less than 2.

@doc {heading:'Operations',
      subheading:'Linear Algebra',
      namespace:'linalg'}