code: def validate_polygon(obj):
      
      if isinstance(obj, Polygon):
          polygon = obj
      elif util.is_shape(obj, (-1, 2)):
          polygon = Polygon(obj)
      elif util.is_string(obj):
          polygon = load_wkb(obj)
      else:
          raise ValueError('Input not a polygon!')
  
      if (not polygon.is_valid or
              polygon.area < tol.zero):
          raise ValueError('Polygon is zero- area or invalid!')
      return polygon
docs: Make sure an input can be returned as a valid polygon.
  
      Parameters
      -------------
      obj : shapely.geometry.Polygon, str (wkb), or (n, 2) float
        Object which might be a polygon
  
      Returns
      ------------
      polygon : shapely.geometry.Polygon
        Valid polygon object
  
      Raises
      -------------
      ValueError
        If a valid finite- area polygon isn't available