LOS ANGELES — Four teens were charged Tuesday with murder in the fatal beating of a University of Southern California graduate student with a baseball bat and wrench as he walked to his off-campus apartment after meeting with a study group.

Two of the suspects, ages 16 and 17, were charged as adults in the slaying of Xinran Ji, 24, an engineering student from China who was attacked early Thursday.

He was able to make his way to his apartment despite being hit in the head with the bat. A roommate discovered him dead hours later.

The defendants — 17-year-old Alberto Ochoa, 16-year-old Alejandra Guerrero, 18-year-old Andrew Garcia and 19-year-old Jonathan Del Carmen — will be arraigned Aug. 12 on one count each of murder with a special circumstance of murder in the course of an attempted robbery.

Garcia, Ochoa and Guerrero also face a special allegation that they personally used a dangerous weapon — the bat and wrench.

In 2012, two USC students from China were fatally shot during an off-campus robbery also during the early morning.

“For any family this is a horrible tragedy, but it’s magnified by the fact that these Chinese families have sent their children so far away expecting that this was the best possible thing…and now he’s gone,” Clayton Dube, executive director of the USC U.S.-China Institute, said about Ji.

Dube said the university along with the U.S. and Chinese governments were working to get Ji’s parents to Los Angeles from Hohhot, the capital city of Inner Mongolia in northern China.

Ji had excelled at one of China’s best universities and came to California several years ago on a tour. He decided then that he wanted to attend graduate school in the U.S.

“He was somebody who wanted to understand how things worked,” Dube said.

Ji, who was halfway through his master’s program and taking a summer engineering course, had just escorted a study partner home when he was attacked, Dube said.

The consulate general of The People’s Republic of China in Los Angeles called Ji’s death cruel and said it was concerned about student safety.

Students were reminded to take extra security precautions and representatives reached out to U.S. authorities to take measures to ensure the safety of Chinese students, according to a statement from the consulate.

Meanwhile, Chinese students have traded messages of sadness and shock over the death of Ji, and a Taiwanese student association sent out a long message with security tips.

Attorney Daniel Deng, who is representing the family of the students killed in 2012 on a pro bono basis, urged the Chinese government to declare USC an unsafe place to study.

The attack prompted USC to review its program for educating foreign students about safety issues, said USC Department of Public Safety Deputy Chief David Carlisle.

“There will be improvements by the fall semester,” Carlisle said. “We already do a pretty good job, but clearly there are areas to improve.”

The university has the highest number of international students in the country, with more than 40 percent of them coming from China.

Garcia, Ochoa and Guerrero were also charged with one count each of second-degree robbery, attempted second-degree robbery and assault with a deadly weapon in another incident the same morning. Ocho and Guerrero were armed with a knife and bat in that incident, the complaint states.

Police believe the attackers drove to Dockweiler Beach after from the USC area and tried to rob a man and woman. The man escaped and notified police.

If convicted, Garcia and Del Carmen could face the death penalty for Ji’s death. However, Ochoa and Guerrero can only face up to life in prison without possibility of parole because of their ages. All four are being held without bail.

USC’s urban campus is within a mile of gang-plagued neighborhoods with historically high crime rates.

Since the 2012 killings, USC has added 60 security cameras, including some license plate readers, for a total of 178 cameras in a 1.8 square mile area that includes blocks off campus, Carlisle said.

The university also deploys private security officers in the adjacent neighborhood.

In addition, the Los Angeles Police Department has assigned about 30 more officers to the university community since 2012.

Foreign students receive a fall orientation that specifically addresses public safety, Carlisle said, but the school is now looking at ways to make it more robust and to find better ways to reach out to students, including possibly in their native languages.

Other proposals include looking at how officers are deployed, whether there should be more officers and whether those should be private security or Los Angeles police officers.

The university is also looking at technological aids as well, including cellphone applications.