code: def ds_extent(ds, t_srs=None):
      
      ul, ll, ur, lr = gt_corners(ds.GetGeoTransform(), ds.RasterXSize, ds.RasterYSize) 
      ds_srs = get_ds_srs(ds) 
      if t_srs is not None and not ds_srs.IsSame(t_srs):
          ct = osr.CoordinateTransformation(ds_srs, t_srs)
          #Check to see if ct creation failed
          #if ct == NULL:
          #Check to see if transform failed
          #if not ct.TransformPoint(extent[0], extent[1]):
          #Need to check that transformed coordinates fall within appropriate bounds
          ul = ct.TransformPoint(*ul)
          ll = ct.TransformPoint(*ll)
          ur = ct.TransformPoint(*ur)
          lr = ct.TransformPoint(*lr)
      extent = corner_extent(ul, ll, ur, lr)
      return extent
docs: Return min/max extent of dataset based on corner coordinates
  
      xmin, ymin, xmax, ymax
  
      If t_srs is specified, output will be converted to specified srs