<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _extract_nn_info(self, structure, nns):
 """Given Voronoi NNs, extract the NN info in the form needed by NearestNeighbors Args: structure (Structure):
 Structure being evaluated nns ([dicts]):
 Nearest neighbor information for a structure Returns: (list of tuples (Site, array, float)):
 See nn_info """


        # Get the target information
        if self.targets is None:
            targets = structure.composition.elements
        else:
            targets = self.targets

        # Extract the NN info
        siw = []
        max_weight = max(nn[self.weight] for nn in nns.values())
        for nstats in nns.values():
            site = nstats['site']
            if nstats[self.weight] > self.tol * max_weight \
                    and self._is_in_targets(site, targets):
                nn_info = {'site': site,
                           'image': self._get_image(structure, site),
                           'weight': nstats[self.weight] / max_weight,
                           'site_index': self._get_original_site(
                               structure, site)}

                if self.extra_nn_info:
                    # Add all the information about the site
                    poly_info = nstats
                    del poly_info['site']
                    nn_info['poly_info'] = poly_info
                siw.append(nn_info)
        return siw