input: Write a function to create an object-oriented structure in Python that solves a maze. The Maze class should initialize with dimensions n x m, and the solve_maze method should find and return the shortest path from the start (0, 0) to the end (n-1, m-1) within the maze grid. The maze grid contains 1s where the path is valid and 0s or None elsewhere. If the path is found, return the path length; otherwise, return an empty list.
  assert Maze(3, 3).solve_maze() == []
  assert Maze(4, 4).solve_maze() == []
  assert Maze(2, 2)._grid == [[None, None], [None, None]]
  assert Maze(5, 5)._grid == [[None]*5 for _ in range(5)]
  assert Maze(1, 1).solve_maze() == []
output: def __init__(self, n, m):
      self._grid = [[None]*m for _ in range(n)]
      self.n = n
      self.m = m
  
  def solve_maze(self):
      if self._grid[0][0] != 1 or self._grid[self.n-1][self.m-1] != 1:
          return []
      
      from collections import deque
      queue = deque([(0, 0, 1)])
      visited = set((0, 0))
      
      directions = [(0, 1), (1, 0), (0, -1), (-1, 0)]
      
      while queue:
          x, y, path_length = queue.popleft()
          
          if (x, y) == (self.n-1, self.m-1):
              return path_length
          
          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, path_length + 1))
      
      return []