function diag_(x) {
    const $x = (0, _tensorUtilEnv.convertToTensor)(x, "x", "diag");
    const inputs = {
        x: $x
    };
    return (0, _engine.ENGINE).runKernel((0, _kernelNames.Diag), inputs);
}
Returns a diagonal tensor with given diagonal values.

Given a diagonal, this operation returns a tensor with the diagonal and
everything else padded with zeros.

Assume the input has dimensions `[D1,..., Dk]`, then the output is a tensor
of rank 2k with dimensions `[D1,..., Dk, D1,..., Dk]`

```js
const x = tf.tensor1d([1, 2, 3, 4]);

tf.diag(x).print()
```
```js
const x = tf.tensor2d([1, 2, 3, 4, 5, 6, 7, 8], [4, 2])

tf.diag(x).print()
```
@param x The input tensor.

@doc {heading: 'Tensors', subheading: 'Creation'}