The South African government is prepared to accept an independent Rhodesia ruled by either of the nationalist guerrilla leaders against whom it helped the white Rhodesian minority wage a war for seven years.

While Robert Mugabe would not be the South Africans' first choice, Pretoria feels it could live with a government headed by the Marxist guerrilla leader. Officials here think Mugabe would provide strong leadership, yet would need economic ties with South Africa.

Far more favorable, however in the view of many South Africans, would be a government led jointly by former prime minister Abel Muzorewa and Joshua Nkomo, a guerrilla leader considered less radical than Mugabe.

Conversations with South African political and military officials and others close to the government indicate that this readiness to accept a guerrilla-led Rhodesia is a result of South Africa's disillusionment with the man it helped make Rhodesia's first black prime minister last year.

It also stems from a pragmatic South African adaptation to changed circumstances in Rhodesia brought about by the British-arranged peace settlement.

Thus, Pretoria has accepted, although reluctantly, the premise of U.S. and British diplomats devising peaceful solutions to the racial conflicts in southern Africa -- that the men with the guns must also be included for a workable solution.

It was South Africa's belief they could be excluded that led it to support former prime minister Ian Smith's 1978 accord with three internal black leaders that eventually put Muzorewa in power last June.

"It's clear now that you cannot have a settlement without accommodation with the external opposition forces," said a South African political science professor, Andre du Pisani. He suggested that this attitude might also spill over into South Africa's negotiations over the future of the territory of Southwest Africa (Namibia).

"Muzorewa is a weak leader," said one South African military official in a background discussion. "The worst thing that could happen in my personal opinion would be if Muzorewa won by a landslide" in Rhodesian parliamentary elections this week, he said.

Another government official said the South Africans had also taken note of Muzorewa's apparent declining popularity among blacks in Rhodesia since the return of Mugabe and his fellow guerrilla leader Joshua Nkomo last month.

South African officials indicate that their preference at the moment is a coalition government led by Muzorewa and Nkomo. Muzorewa, concerned about keeping whites in Rhodesia, would provide a moderating influence on economic policy, they think, while Nkomo, whom South Africa does not consider a Marxist, would provide the political savvy and authority.

As a longtime national leader with guerrilla credentials, Nkomo could also give the government respectability and credibility in the international community.

Some observers even feel that the cloud of a Mugabe government would have a silver lining for South Africa, intent upon surrounding itself with a buffer zone of economically dependent states.

Their theory is that like Mozambique and Angola, a Mugabe-headed socialist government in Rhodesia would attract less Western investment than would a moderate, less anti-Western regime led by Nkomo and Muzorewa. There would thus be more opportunities for South Africa to step in with technical aid, loans, food and products as it has in Mozambique, increasing Rhodesia's economic dependence on Pretoria, according to this theory.

"One of the paradoxes of a Mugabe Marxist regime would be its increased dependence on Pretoria," said one South African academic. "In an odd way, if Mugabe could stabilize Rhodesia, he might not be unwelcome in Pretoria."

The South Africans' first choice, an Nkomo-led coalition, is not without hazards to this country. Nkomo has longstanding ties with South Africa's banned black nationalist guerrilla movement, the South African National Congress. Unlike Mugabe, Nkomo has never said publicly that he would deny sanctuary or bases in Rhodesia to guerrillas fighting for the Congress.

Secondly, throughout the guerrilla war in Rhodesia, Nkomo enjoyed a closer relationship with the Soviet Union than did Mugabe, who got most of his arms from China and Eastern Bloc countries such as Romania and Yugoslavia.

"What's he going to do about the Soviets?" asked one South African official.

The main question now is what military role, if any, South Africa will play over the next few months as the British conduct elections, set up a new Rhodesian government and then hastily depart.

Ever since the settlement talks began last September, South Africa has been making bellicose statements implying it would intervene militarily in Rhodesia under certain circumstances. These included the necessity to assist a mass white exodus or to counter intervention by East Germans or Cubans, which most observers consider an unlikely possibility.

A third reason given by South Africa for possible intervention would be "chaos, confusion and instability," code words in South Africa for a host of problems it does not want: streams of black and white refugees needing food and aid; an influx of hostile whites who would strengthen the rightist backlash against domestic change the government hopes to achieve here, or damage to Rhodesia's rail and road systems that could hurt South Africa's plans for expanded commercial ties.

"Stability has become a political value in itself," said Du Pisani. In fact, the impression is left that, despite Pretoria's anti-Marxist declarations, a strong, stable government is preferred over the establishment of a non-Marxist regime.

South Africans are fully aware of the political risks they would run if they openly intervened militarily in Rhodesia.

This would provide a "wonderful rationalization" for foreign intervention, said Du Pisani. It would jeopardize negotiations to get a peace settlement in Namibia. It would taint the Rhodesian leaders the South Africans had ostensibly come to "rescue" and it would present South Africa with a war that would drain manpower and resources earmarked for expanded domestic economic development.

In addition, it could wreck Pretoria's plans for a "constellation" of southern states linked to South Africa by economic and, eventually, diplomatic ties.

So despite a hawk faction in South Africa that would like to "take a stand against the Marxists [and] secure our sphere of influence" as one official put it, South Africa's publicized threats of military action in Rhodesia are believed to be saber-rattling. At first it was intended to pressure Britain at the London settlement talks and, later, to warn Mugabe and his backer, Mozambican President Samora Machel, against thoughts of restarting the guerrilla war should Mugabe fail to win power.

The saber-rattling has already had some results. Mugabe has publicly stated that his government would not give bases to guerrillas fighting South Africa. In a meeting in Salisbury with the deputy head of the South African mission there, Mugabe repeated those assurances, asking for similar ones of nonintervention from the South Africans, according to sources in Mugabe's party.