input: Write a python function to calculate the average of all elements in a 2D matrix.
  assert averageMatrix([[3, 2, 6], [8, 5, 9], [4, 7, 1]]) == 4.777777777777778
  assert averageMatrix([[1, 2], [3, 4]]) == 2.5
  assert averageMatrix([[10, 20], [30, 40], [50, 60]]) == 35.0
output: def averageMatrix(matrix):
      total_sum = sum(sum(row) for row in matrix)
      total_elements = sum(len(row) for row in matrix)
      return total_sum / total_elements