input: Write a python function that processes an m x n matrix called 'image' representing a grayscale image (image[i][j] is the pixel intensity in the range 0 to 255) and a non-negative integer 'threshold'. Two pixels are deemed adjacent if they share a border. A region is defined as a 3 x 3 subgrid where the absolute difference in intensity between any two adjacent pixels is at most 'threshold'. Each pixel can be part of multiple regions. The function should compute another m x n matrix named 'result' where result[i][j] is the average intensity of all regions that image[i][j] belongs to, rounded down to the nearest integer. If image[i][j] does not belong to any region, result[i][j] should be the same as image[i][j].
output: def process_image(image, threshold):
      def in_bounds(i, j, m, n):
          return 0 <= i < m and 0 <= j < n
  
      def get_region_average(i, j, m, n, image, threshold):
          coords = [
              (i + di, j + dj)
              for di in range(-1, 2)
              for dj in range(-1, 2)
              if in_bounds(i + di, j + dj, m, n)
          ]
          region_pixels = [image[x][y] for x, y in coords]
          if all(
              abs(image[i][j] - image[x][y]) <= threshold
              for x, y in coords
              if (x, y) != (i, j)
          ):
              return sum(region_pixels) // len(region_pixels)
          return image[i][j]
  
      m, n = len(image), len(image[0])
      result = [[image[i][j] for j in range(n)] for i in range(m)]
  
      for i in range(m):
          for j in range(n):
              result[i][j] = get_region_average(i, j, m, n, image, threshold)
      
      return result