function ensureShape_(x, shape) {
    const $x = (0, _tensorUtilEnv.convertToTensor)(x, "x", "ensureShape", "string_or_numeric");
    if (!(0, _utilBase.arraysEqualWithNull)($x.shape, shape)) throw new Error(`EnsureShape: Shape of tensor ${$x.shape} is not compatible with expected shape ${shape}`);
    return x;
}
Checks the input tensor mathes the given shape.

Given an input tensor, returns a new tensor with the same values as the
input tensor with shape `shape`.

The method supports the null value in tensor. It will still check the shapes,
and null is a placeholder.


```js
const x = tf.tensor1d([1, 2, 3, 4]);
const y = tf.tensor1d([1, null, 3, 4]);
const z = tf.tensor2d([1, 2, 3, 4], [2,2]);
tf.ensureShape(x, [4]).print();
tf.ensureShape(y, [4]).print();
tf.ensureShape(z, [null, 2]).print();
```

@param x The input tensor to be ensured.
@param shape A TensorShape representing the shape of this tensor, an array
    or null.

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