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