def gram(self):
        """Generate the gram matrix (lazy loading).

        Only access this function after a `.fit()` (otherwise
        `self.signal` is not defined).
        """
        if self._gram is None:
            self._gram = squareform(1 - pdist(self.signal, metric="cosine"))
        return self._gram
Generate the gram matrix (lazy loading).

        Only access this function after a `.fit()` (otherwise
        `self.signal` is not defined).
        
src/ruptures/costs/costcosine.py