<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def weighted_averages(self):
 """ Access to the weighted averages of the values at the vertices for each triangle based on the weights provided by mesh.weights. This is most useful for partially visible triangles when using libphoebe's eclipse detection that returns weights for each vertex. Note that weights by default are set to 1/3 for each vertex, meaning that this will provide the same values as :meth:`averages` unless the weights are overridden within the mesh. If the quantities are defined at centers instead of vertices, this will return None. :return: numpy array or None """

        if not self.mesh._compute_at_vertices:
            return None

        vertices_per_triangle = self.vertices_per_triangle
        if vertices_per_triangle.ndim==2:
            # return np.dot(self.vertices_per_triangle, self.mesh.weights)
            return np.sum(vertices_per_triangle*self.mesh.weights, axis=1)
        elif vertices_per_triangle.ndim==3:
            return np.sum(vertices_per_triangle*self.mesh.weights[:,np.newaxis], axis=1)
        else:
            raise NotImplementedError