input: 
  from typing import List
  
  def averageMatrix(matrix: List[List[float]]) -> float:
      """Calculate the average of all elements in a 2-dimensional array.
      >>> a = [[3, 2, 6], [8, 5, 9], [4, 7, 1]]
      >>> averageMatrix(a)
      4.77
      """
      sum_elements = 0
      for row in matrix:
          for element in row:
              sum_elements += element
  
      return round(sum_elements / (len(matrix) * len(matrix[0])), 2)
  
output:     sum_elements = 0
      for row in matrix:
          for element in row:
              sum_elements += element
  
      return round(sum_elements / (len(matrix) * len(matrix[0])), 2)