Human: Help me to optimize this code:
doe = DistanceOnEarth()
def get_mdr_distance(row):
    route_geom = shapely.wkt.loads(row.provider_route)
    route_points = route_geom.coords[:]
    mdr_points = []
    mdr_distance = 0
    for points in split_list(route_points):
        point_1, point_2 = points
        line = shapely.geometry.LineString(points)
        is_mdr = (
            requests.post(
                MDR_URL,
                data=line.wkt,
                headers={"accept": "*/*", "Content-Type": "text/plain"},
            ).content
            == b"true"
        )
        if is_mdr:
            mdr_points.extend(points)
        else:
            if len(mdr_points) > 0:
                mdr_points.extend([point_1])
                mdr_distance += doe.get_4326_geometry_length_in_m(shapely.LineString(mdr_points))
                mdr_points = []
    if len(mdr_points) > 0:
        mdr_distance += doe.get_4326_geometry_length_in_m(shapely.LineString(mdr_points))
    return mdr_distance

Assistant: One way to optimize this code is by reducing the number of requests made to the server and refactoring the loop to make it more efficient. Here's the modified code:

```python

    import requests
    import shapely.wkt
    import shapely.geometry
    from distance_on_earth import DistanceOnEarth  # Assuming this is the correct import
    
    doe = DistanceOnEarth()

    def get_mdr_distance(row):
        route_geom = shapely.wkt.loads(row.provider_route)
        route_points = route_geom.coords[:]
        
        def chunks(lst, n=2):
            for i in range(0, len(lst) - 1, n - 1):
                yield lst[i:i + n]
        
        line_segments = list(chunks(route_points))
        request_lines = [shapely.geometry.LineString(pair).wkt for pair in line_segments]
        request_payload = "\n".join(request_lines)
        
        response = requests.post(
            MDR_URL,
            data=request_payload,
            headers={"accept": "/", "Content-Type": "text/plain"},
        )
    
        is_mdr_list = response.content.decode().split('\n')
        
        mdr_points = []
        mdr_distance = 0
        for points, is_mdr in zip(line_segments, is_mdr_list):
            point_1, point_2 = points
            if is_mdr == "true":
                mdr_points.extend(points)
            else:
                if mdr_points:
                    mdr_points.append(point_1)
                    mdr_distance += doe.get_4326_geometry_length_in_m(shapely.geometry.LineString(mdr_points))
                    mdr_points = []
        
        if mdr_points:
            mdr_distance += doe.get_4326_geometry_length_in_m(shapely.geometry.LineString(mdr_points))
        
        return mdr_distance
```

Here's a summary of the changes made:

1. Created a helper function `chunks` to split the list of route points into pairs.
2. Combined all the LineStrings into a single request payload to reduce the number of requests made to the server.
3. Parsed the response content to obtain a list of `is_mdr` values.
4. Modified the loop to use the zip function to iterate over line_segments and `is_mdr_list` simultaneously.

This should improve the performance of the code by reducing the number of requests made to the server and simplifying the loop logic. Make sure to test the modified code to ensure it still meets your requirements.