Non-canonical backlinks

I’ll describe my problem.

I have site A1, and the URL 1: https://example1.com/link

I also have another site A2, and the URL 2: https://example2.com/link. This webpage has a canonical URL point to the URL 1: https://example1.com/link by using link tag:

// source code "https://example2.com/link"  <link rel="canonical" href="https://a1.com/link" /> 

Now, suppose the URL 2 is shared many times as backlinks. So which URL will benefit in SEO?