code: def _to_geo_point(
      closest_place: Optional[Union[Geocodes, ShapelyPointType]]
  ) -> Optional[GeoPoint]:
      if closest_place is None:
          return None
  
      if isinstance(closest_place, Geocoder):
          closest_place = closest_place._geocode()
  
      if isinstance(closest_place, Geocodes):
          closest_place_id = closest_place.as_list()[0].unique_ids()
          assert len(closest_place_id) == 1
  
          request = (
              RequestBuilder()
              .set_request_kind(RequestKind.explicit)
              .set_requested_payload([PayloadKind.centroids])
              .set_ids(closest_place_id)
              .build()
          )
  
          response: Response = GeocodingService().do_request(request)
          if isinstance(response, SuccessResponse):
              assert len(response.features) == 1
              centroid = response.features[0].centroid
              return GeoPoint(lon=centroid.lon, lat=centroid.lat)
          else:
              raise ValueError(
                  "Unexpected geocoding response for id "
                  + str(closest_place_id[0])
              )
  
      if LazyShapely.is_point(closest_place):
          return GeoPoint(lon=closest_place.x, lat=closest_place.y)
  
      raise ValueError(
          "Not supported type: {}".format(type(closest_place))
      )
  
imports: from collections import namedtuple
  from collections.abc import Iterable
  from typing import Union, List, Optional, Dict
  from pandas import Series
  from .geocodes import _to_level_kind, request_types, Geocodes, _raise_exception, _ensure_is_list
  from .gis.geocoding_service import GeocodingService
  from .gis.geometry import GeoRect, GeoPoint
  from .gis.request import RequestBuilder, GeocodingRequest, RequestKind, MapRegion, AmbiguityResolver, RegionQuery, LevelKind, IgnoringStrategyKind, PayloadKind, ReverseGeocodingRequest
  from .gis.response import Response, SuccessResponse
  from .type_assertion import assert_list_type
label_desc: Use image node_id 3 for calling a global function with example usage: _to_geo_point(closest_place) and returns: None, GeoPoint, GeoPoint