input: Write a function to find the shortest path between two points in a matrix. Use the BFS (Breadth-First Search) algorithm for this purpose. The function should return the minimum length of the path between the start and end points. If the start or end points are invalid (outside the matrix), the function should return math.inf.
  
  assert shortest_path([[2, 3, 5], [1, 7, 6], [3, 0, 9]], (0, 0), (2, 2)) == 5
  assert shortest_path([[2, 3, 5], [1, 7, 6], [3, 0, 9]], (0, 0), (2, 1)) == math.inf
  assert shortest_path([[0, 1, 0], [0, 0, 0], [1, 1, 0]], (0, 0), (2, 2)) == 5
  assert shortest_path([[1, 1, 1], [0, 0, 0], [1, 1, 1]], (1, 0), (1, 2)) == 3
output: import math
  
  def shortest_path(matrix, start, end):
      if start[0] < 0 or start[0] >= len(matrix) or start[1] < 0 or start[1] >= len(matrix[0]):
          return math.inf
      if end[0] < 0 or end[0] >= len(matrix) or end[1] < 0 or end[1] >= len(matrix[0]):
          return math.inf
      
      directions = [(0, 1), (1, 0), (0, -1), (-1, 0)]
      queue = [(start[0], start[1], 0)]
      visited = set()
      visited.add(start)
      
      while queue:
          x, y, dist = queue.pop(0)
          
          if (x, y) == end:
              return dist
          
          for dx, dy in directions:
              nx, ny = x + dx, y + dy
              if 0 <= nx < len(matrix) and 0 <= ny < len(matrix[0]) and (nx, ny) not in visited:
                  visited.add((nx, ny))
                  queue.append((nx, ny, dist + 1))
      
      return math.inf