function resizeNearestNeighbor_(images, size, alignCorners = false, halfPixelCenters = false) {
    const $images = (0, _tensorUtilEnv.convertToTensor)(images, "images", "resizeNearestNeighbor");
    _util.assert($images.rank === 3 || $images.rank === 4, ()=>`Error in resizeNearestNeighbor: x must be rank 3 or 4, but got ` + `rank ${$images.rank}.`);
    _util.assert(size.length === 2, ()=>`Error in resizeNearestNeighbor: new shape must 2D, but got shape ` + `${size}.`);
    _util.assert($images.dtype === "float32" || $images.dtype === "int32", ()=>"`images` must have `int32` or `float32` as dtype");
    _util.assert(halfPixelCenters === false || alignCorners === false, ()=>`Error in resizeNearestNeighbor: If halfPixelCenters is true, ` + `alignCorners must be false.`);
    let batchImages = $images;
    let reshapedTo4D = false;
    if ($images.rank === 3) {
        reshapedTo4D = true;
        batchImages = (0, _reshape.reshape)($images, [
            1,
            $images.shape[0],
            $images.shape[1],
            $images.shape[2]
        ]);
    }
    const [] = size;
    const inputs = {
        images: batchImages
    };
    const attrs = {
        alignCorners,
        halfPixelCenters,
        size
    };
    // tslint:disable-next-line: no-unnecessary-type-assertion
    const res = (0, _engine.ENGINE).runKernel((0, _kernelNames.ResizeNearestNeighbor), inputs, attrs);
    if (reshapedTo4D) return (0, _reshape.reshape)(res, [
        res.shape[1],
        res.shape[2],
        res.shape[3]
    ]);
    return res;
}
NearestNeighbor resize a batch of 3D images to a new shape.

@param images The images, of rank 4 or rank 3, of shape
    `[batch, height, width, inChannels]`. If rank 3, batch of 1 is assumed.
@param size The new shape `[newHeight, newWidth]` to resize the
    images to. Each channel is resized individually.
@param alignCorners Defaults to False. If true, rescale
    input by `(new_height - 1) / (height - 1)`, which exactly aligns the 4
    corners of images and resized images. If false, rescale by
    `new_height / height`. Treat similarly the width dimension.
@param halfPixelCenters Defaults to `false`. Whether to assume pixels are of
     half the actual dimensions, and yield more accurate resizes. This flag
     would also make the floating point coordinates of the top left pixel
     0.5, 0.5.

@doc {heading: 'Operations', subheading: 'Images', namespace: 'image'}