code: def outer_product(vec):
      r
      return (
          np.dot(vec[:, np.newaxis], vec[np.newaxis, :])
          if len(vec.shape) == 1 else
          np.dot(vec, vec.T)
          )
docs: r"""
      Returns the outer product of a vector :math:`v`
      with itself, :math:`v v^\T`.