input: 
  from typing import List
  
  def solve_maze(n: int, m: int, grid: List[List[int]]) -> List[int]:
      """
      Solve the maze by creating an instance of the Maze class, initializing it with the given dimensions and grid, and calling the solve_maze method.
      The solve_maze method should return the shortest path length from the top-left corner (0,0) to the bottom-right corner (n-1, m-1) in the maze.
      If there is no path, it returns an empty list.
      >>> grid = [[1, 0, 0, 0], [1, 1, 0, 1], [0, 1, 0, 0], [1, 1, 1, 1]]
      >>> solve_maze(4, 4, grid)
      [7]
      >>> grid = [[1, 0, 0, 0], [1, 1, 0, 1], [0, 1, 0, 0], [1, 0, 1, 1]]
      >>> solve_maze(4, 4, grid)
      []
      """
      maze = Maze(n, m)
      maze._grid = grid
      return maze.solve_maze()
  
output:     from collections import deque
  
      class Maze:
          def __init__(self, n, m):
              self.n = n
              self.m = m
              self.grid = [[0] * m for _ in range(n)]
          
          def solve_maze(self):
              if self.grid[0][0] == 0 or self.grid[self.n-1][self.m-1] == 0:
                  return []
              
              directions = [(0, 1), (1, 0), (0, -1), (-1, 0)]
              queue = deque([(0, 0, 0)])
              visited = set((0, 0))
              
              while queue:
                  x, y, dist = queue.popleft()
                  
                  if x == self.n - 1 and y == self.m - 1:
                      return [dist + 1]
                  
                  for dx, dy in directions:
                      nx, ny = x + dx, y + dy
                      if 0 <= nx < self.n and 0 <= ny < self.m and (nx, ny) not in visited and self.grid[nx][ny] == 1:
                          visited.add((nx, ny))
                          queue.append((nx, ny, dist + 1))
              
              return []