modified the code format of cosine.py