The latest class of Salvadoran government troops trained by the U.S. military to fight leftist rebels was graduated from this infantry base today during an emotional ceremony in which one of their leaders said, "We should be willing to give up our lives for the benefit of our country and our children's children."

Col. Luis Alberto Landaverde, director of El Salvador's Military Academy in San Salvador, told the 174 Salvadoran cadets that the survival of their country's form of government will depend heavily on how they perform in combat.

"You have the gift of liberty," he said, "a gift that is not found in communist regimes."

Landaverde flew here from El Salvador to congratulate the cadets for passing the rugged infantry course and to thank the U.S. military for providing training in how to beat guerrillas at their own game of hit and run.

The cadets, who had been "shooting" at each other for 15 weeks during training days that started at 4 a.m. and ended at 11 p.m., sat stiff-backed but attentive in the base movie theater used for the graduation ceremony.

In the exercises the young Salvadorans shot at each other with M16 rifles that sent out laser beams that set off beepers when a cadet was hit.

Within a few weeks, the Salvadorans, many of them only 19, will be shooting at guerrillas back home.

American training officers said the Salvadoran troops who were trained in previous infantry courses at Fort Benning and Fort Bragg, N.C., have been so aggressive against guerrillas in El Salvador that the war is going the government's way militarily, if not politically.

The Reagan administration says it believes so firmly that the infantry training the Salvadorans have received at Fort Benning and Fort Bragg is vital to the success of Salvadoran government forces that it will be replicated by U.S. trainers at camps under construction in Honduras.

On a typical day for the cadets, a M60 machine gun shot a steady bam, bam, bam of covering fire into the building as two Salvadoran soldiers rushed along its side, heading for the open window. Their mission was to get inside without getting killed.

This time it was training. The enemy fire sounded real but consisted of laser beams that followed the path bullets would take. Sensors on their bodies beeped if a laser beam hit them.

Both soldiers crouched low next to the open window, backs pressed against the wall. One grabbed the window ledge to pull himself into the building. He could not do it on the first try. He laid his rifle inside the room, then pulled himself inside with both hands and a boost from his buddy on the ground.

"What did he do wrong?" the Spanish-speaking U.S. Army drill sergeant demanded of the group of Salvadorans sitting a tiny grandstand under the 100-degree sun at the Fort Benning training complex.

"Didn't fire his rifle before going into the room," one of the Salvadoran cadets answered correctly with undisguised glee.

"Didn't throw in a grenade," responded another, also correctly.

The cadets were going to assault the building again and again until they did it right. The trainers said that the Salvadorans complained a lot less about this than would their American counterparts in similar training for small-unit combat operations.

"They are a little more motivated," said Capt. Angel Hernandez, 28, a native of Puerto Rico, who was in charge of training one of the three companies of Salvadoran cadets at Fort Benning. He said the Salvadorans know their lives may soon depend on doing the right thing in fighting guerrillas.

Sgt. Ernesto Berber, 34, who also is fluent in Spanish, is one of 10 non-commissioned officers who try to make a first-class fighting outfit from a company of inexperienced Salvadorans in 15 weeks. As chief instructor for almost 200 Salvadorans, he broke each combat operation into several parts and kept repeating them until the trainees stopped getting hit by the laser beams simulating enemy fire.

There were, for example, five separate exercises over two days to teach the cadets how to take or defend a building in a small city. The cadets trying to get into the window were on step two of this drill. Still to come were throwing a grappling hook through an upper-story window and climbing up the building by the rope attached to the hook.

"It's always better to take a building from the top down rather from the bottom up," said Berber. "But not everybody is strong enough to do it. They're just like our own soldiers that way."

The Salvadorans were under attack by mock guerrillas during their entire stay at Fort Benning. They were not allowed to walk on the roads during training days. They constantly had to watch out for ambush parties, which, when they set off the beepers on the Salvadorans, provoked the wrath of the colonel in charge of training all three Salvadoran companies going through Fort Benning this year.

"I'm that little s.o.b. who gets them up in the middle of the night and who won't let them eat when they're hungry and tired until they find by their compass where I've put the food," said Lt. Col. Reynaldo A. Garcia, a fiery Cuban who said he had conducted 26 night raids against Fidel Castro's Cuba.

He said that he deserted from the Cuban army in 1959, worked with anti-Castro saboteurs until he was a hunted man, escaped to the United States with a false passport and worked with Cuban exile forces intermittently until joining the U.S. Army in 1963.

Garcia said "I know" how dangerous it is to fight experienced guerrillas. He added that he does not expect the Salvadoran cadets to like him for the harsh training he puts them through.

"It's a lot harder" than what U.S. enlistees or officer cadets receive at Fort Benning, he said, because it is tailored expressly for combating hit-and-run forces.

"I give these cadets only five blank bullets for a training operation," he said. "I tell them if you fire them all, you may not have any when you need them. They've got to learn fire discipline for what they're going to be doing.

"I tell them they're aren't going to be any Chinooks heavy lift helicopters used by U.S. forces in Vietnam to bring in ammunition or cold beer or ice cream. They've got to survive on what they carry."

Garcia stressed the need to break down companies of Salvadoran troops into squads of 20 to 30 men to cover more ground and present a smaller target to the guerrillas.

"I've made all the roads at Fort Benning off limits to these cadets," he said. "I insist they stay off the roads when they travel and to expect an ambush wherever they go."

In Garcia's view, the Salvadorans who received the U.S. small-unit training have become first-class infantryman. "I would take them anywhere," he said. "I would take them to Moscow tomorrow, by parachute."

Garcia said that he will take his training methods to El Salvador in about six months when he becomes one of the 55 U.S. trainers the administration keeps there on a rotation basis. Fort Benning is scheduled to stop training Salvadorans next month.

Garcia and other Spanish-speaking American trainers here project a deep sense of mission in trying to explain why they work so hard to turn the young Salvadorans into first-class soldiers who can win against the guerrillas.

"The threat is next door now," Garcia said of the leftist forces he sees on the move in Central America. "Either we stop them somewhere there or my last stand is going to be in a foxhole along the Chattahootchee River with my wife and family on either side of me.

"Maybe if we help them to do the job," he said of the Salvadorans, "the Russians will realize that they're not going to get anymore. And my son, Reynaldo, will not have to go down there" to Central America to fight.

Capt. Victor Tise, 27, another U.S. infantry officer who has trained Salvadoran cadets at Fort Benning, said much the same thing. He was among those who claim that the cadets trained by the United States already have proved so aggressive that they have the rebels on the run in El Salvador.

"As platoon leaders," he said of the cadets, "they can make a big difference. Battles are won down at the small-unit level, not the large-unit level."

"What I'm doing here has a purpose," said trainer Hernandez. "If they take care of the guerrillas, we don't have to send our troops down there."

A key question about the Salvadoran military, however, is whether it can win and hold the support of the Salvadoran people.

"You will be expected to set the example," Maj. Gen. James J. Lindsay, commandant of the infantry school here and a veteran of the Vietnam War, told the Salvadoran cadets today at their graduation ceremony. "Maintaining the support of the people is as important as winning battles in combat."

Perhaps in hopes of reassuring Lindsay and others, Landaverde said from the flag-bedecked stage of the movie theater, "You may be confident that your instruction will be used for the benefit of human rights."

The Salvadoran cadets stared straight ahead as everyone spoke. After receiving their diplomas, they shouted the Salvadoran "Soldier's Creed" and lustily sang their national anthem.

At ceremony's end, they filed out of the theater and boarded U.S. Army buses to begin their journey toward an uncertain fate in El Salvador. On the movie marquee they passed under was advertised the curent attraction, "Twilight Zone."