input: Write a python function that takes a 2D binary array as input and identifies the smallest rectangular area, aligning with the axes, that contains all the 1's within the grid. The function should return the minimum area of such a rectangle.
  
  
  from typing import List
  
  def smallest_enclosing_rectangle(grid: List[List[int]]) -> int:
      """
      Provided with a 2D binary array grid, determine the rectangle with vertical and horizontal sides that is the smallest in area, encompassing all the 1's in the grid.
  
      Return the least possible area of the identified rectangle.
  
      Examples:
      >>> grid = [[0,1,0],[1,0,1]]
      6
      >>> grid = [[1,0],[0,0]]
      1
  
      Constraints:
      The dimensions of grid and each subarray are between 1 and 1000.
      Each element in grid is either 0 or 1.
      There is at least one 1 included in grid.
      """
  
output: def smallest_enclosing_rectangle(grid: List[List[int]]) -> int:
      rows, cols = len(grid), len(grid[0])
      top, left = rows, cols
      bottom, right = 0, 0
  
      for r in range(rows):
          for c in range(cols):
              if grid[r][c] == 1:
                  top = min(top, r)
                  left = min(left, c)
                  bottom = max(bottom, r)
                  right = max(right, c)
                  
      return (bottom - top + 1) * (right - left + 1)