function getLogicalCoordinatesFromFlatIndex(coords, shape, index = "index") {
    const strides = (0, _tfjsCore.util).computeStrides(shape);
    return strides.map((stride, i)=>{
        const line1 = `int ${coords[i]} = ${index} / ${stride}`;
        const line2 = i === strides.length - 1 ? `int ${coords[i + 1]} = ${index} - ${coords[i]} * ${stride}` : `index -= ${coords[i]} * ${stride}`;
        return `${line1}; ${line2};`;
    }).join("");
}
Produces GLSL that computes the flat index from 3D coordinates.