Will this MAPE implementation work for multidimensional output?
You can either directly use the mean absolute percentage error (MAPE) function in Keras API for TensorFlow or use that function to test your custom function. 

tf.keras.losses.MAPE code is avaible in the TensorFlow GitHub repo:

def mean_absolute_percentage_error(y_true, y_pred):  
  y_pred = ops.convert_to_tensor(y_pred)
  y_true = math_ops.cast(y_true, y_pred.dtype)
  diff = math_ops.abs(
      (y_true - y_pred) / K.maximum(math_ops.abs(y_true), K.epsilon()))
  return 100. * K.mean(diff, axis=-1)