I am Turkish citizen who studies in the USA. I am currently doing study abroad in Germany, so your situation is similar to mine.
Basically, you get an appointment from the nearest Swiss Consulate (the consulate that takes care of the city you are in) and apply for a visa by providing them the documents. It took me 3 months to get a student visa, so beware of the long times. It all depends on the factors present. As long as you are not a Tourist in country Y, you are able to apply for such visa.
Work, Student and Family reunion:
Visa applications for stays longer than 90 days do not require fingerprinting and, therefore, may be submitted by mail. Please note that you might still be invited for an interview. Please read the requirements:
◾AVisa requirements (long stay > 90 days)
Where to apply? Swiss visa desks in Canada
Applications have to be submitted to the Swiss representation competent for your state of residence. Please consult the links below for specific information regarding the application process.
◾Ottawa, Email: Mott.firstname.lastname@example.org
only for diplomatic visas
◾Montreal, Email: Mmon.email@example.com
Provinces of Quebec, Ontario, Manitoba, New Brunswick, Nova Scotia, Prince Edward Island, Newfoundland and Labrador, Territory of Nunavut as well as the Bahama
◾Vancouver, Email: Mvan.firstname.lastname@example.org
Provinces of British Columbia, Alberta, Saskatchewan, the Yukon and Northwest Territories