function gramSchmidt_(xs) {
	  var inputIsTensor2D;

	  if (Array.isArray(xs)) {
	    (function () {
	      inputIsTensor2D = false;
	      assert(xs != null && xs.length > 0, function () {
	        return 'Gram-Schmidt process: input must not be null, undefined, or ' + 'empty';
	      });
	      var dim = xs[0].shape[0];

	      var _loop = function _loop(i) {
	        assert(xs[i].shape[0] === dim, function () {
	          return 'Gram-Schmidt: Non-unique lengths found in the input vectors: ' + ("(" + xs[i].shape[0] + " vs. " + dim + ")");
	        });
	      };

	      for (var i = 1; i < xs.length; ++i) {
	        _loop(i);
	      }
	    })();
	  } else {
	    inputIsTensor2D = true;
	    xs = split$1(xs, xs.shape[0], 0).map(function (x) {
	      return squeeze(x, [0]);
	    });
	  }

	  assert(xs.length <= xs[0].shape[0], function () {
	    return "Gram-Schmidt: Number of vectors (" + xs.length + ") exceeds " + ("number of dimensions (" + xs[0].shape[0] + ").");
	  });
	  var ys = [];
	  var xs1d = xs;

	  var _loop2 = function _loop2(i) {
	    ys.push(ENGINE.tidy(function () {
	      var x = xs1d[i];

	      if (i > 0) {
	        for (var j = 0; j < i; ++j) {
	          var proj = mul(sum$1(mul(ys[j], x)), ys[j]);
	          x = sub(x, proj);
	        }
	      }

	      return div(x, norm(x, 'euclidean'));
	    }));
	  };

	  for (var i = 0; i < xs.length; ++i) {
	    _loop2(i);
	  }

	  if (inputIsTensor2D) {
	    return stack(ys, 0);
	  } else {
	    return ys;
	  }
	}
Gram-Schmidt orthogonalization.

```js
const x = tf.tensor2d([[1, 2], [3, 4]]);
let y = tf.linalg.gramSchmidt(x);
y.print();
console.log('Othogonalized:');
y.dot(y.transpose()).print();  // should be nearly the identity matrix.
console.log('First row direction maintained:');
const data = await y.array();
console.log(data[0][1] / data[0][0]);  // should be nearly 2.
```

@param xs The vectors to be orthogonalized, in one of the two following
  formats:
  - An Array of `tf.Tensor1D`.
  - A `tf.Tensor2D`, i.e., a matrix, in which case the vectors are the rows
    of `xs`.
  In each case, all the vectors must have the same length and the length
  must be greater than or equal to the number of vectors.
@returns The orthogonalized and normalized vectors or matrix.
  Orthogonalization means that the vectors or the rows of the matrix
  are orthogonal (zero inner products). Normalization means that each
  vector or each row of the matrix has an L2 norm that equals `1`.

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