<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def dirichlet_energy(self, x):
 r"""Compute the Dirichlet energy of a signal defined on the vertices. The Dirichlet energy of a signal :math:`x` is defined as .. math:: x^\top L x = \| \nabla_\mathcal{G} x \|_2^2 = \frac12 \sum_{i,j} W[i, j] (x[j] - x[i])^2 for the combinatorial Laplacian, and .. math:: x^\top L x = \| \nabla_\mathcal{G} x \|_2^2 = \frac12 \sum_{i,j} W[i, j] \left( \frac{x[j]}{d[j]} - \frac{x[i]}{d[i]} \right)^2 for the normalized Laplacian, where :math:`d` is the weighted degree :attr:`dw`, :math:`\nabla_\mathcal{G} x = D^\top x` and :math:`D` is the differential operator :attr:`D`. See :meth:`grad` for the definition of the gradient :math:`\nabla_\mathcal{G}`. Parameters x : array_like Signal of length :attr:`n_vertices` living on the vertices. Returns ------- energy : float The Dirichlet energy of the graph signal. See Also -------- grad : compute the gradient of a vertex signal Examples -------- Non-directed graph: 8.0 array([2., 0., 2., 0.]) Directed graph: 4.0 array([1.41421356, 0. , 1.41421356, 0. ]) """

        x = self._check_signal(x)
        return x.T.dot(self.L.dot(x))