How does tf.keras.metrics.IoU calculate mean for 3D?


I have a question about the tf.keras.metrics.IoU function…

How does it calculate the mean IoU when using a 3D volume as input? Does it do a mean of each individual slice (2D image) and then the mean for the whole 3D volume from those, or does it change the whole volume to one big 1D array and outputs a mean of this 1D array?