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