in rfcs/20210731-tfjs-named-tensors/gtensor.ts [248:259]
export function stackGtensors<G extends DName, NewD extends DName>(
newDimName: NewD,
gtensors: GTensor<G>[],
): GTensor<G|NewD> {
if(gtensors.length === 0) {
throw new ValueError('stackDims was empty');
}
const tensors = gtensors.map(g => g.tensor);
const newTensor = tf.stack(tensors);
const newDimNames = [newDimName, ...gtensors[0].dimNames]
return new GTensor(newTensor, newDimNames);
}