<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def infer_location( self, location_query, max_distance, google_key, foursquare_client_id, foursquare_client_secret, limit ):
 """In-place location inferring See infer_location function Args: Returns: :obj:`Segment`: self """


        self.location_from = infer_location(
            self.points[0],
            location_query,
            max_distance,
            google_key,
            foursquare_client_id,
            foursquare_client_secret,
            limit
        )
        self.location_to = infer_location(
            self.points[-1],
            location_query,
            max_distance,
            google_key,
            foursquare_client_id,
            foursquare_client_secret,
            limit
        )

        return self