Question: When did Latvia gain independence from the country that the Russian Federation fought against?

full_context: Document 1: Dievs, svētī Latviju!: The music and lyrics were written in 1873 by Kārlis Baumanis, a teacher, who was part of the Young Latvian nationalist movement. It has been speculated that Baumanis may have borrowed part of the lyrics from a popular song which was sung to tune of God Save the Queen, modified them and set them to music of his own. Baumanis's lyrics were different from the modern ones: he used the term "Baltics" synonymously and interchangeably with "Latvia" and "Latvians", so "Latvia" was actually mentioned only at the beginning of the first verse. Later the term "Latvia" was removed and replaced with "Baltics" to avoid a ban on the song. This has led to the misapprehension that the term "Latvia" was not part of the song until 1920, when it was chosen as national anthem and the word "Baltics" was replaced with "Latvia".During the annexation of Latvia by the Soviet Union, the singing of "Dievs, svētī Latviju!" was banned. The Soviet republic of Latvia had its own anthem. "Dievs, svētī Latviju!" was restored as the state anthem of Latvia on 15 February 1990, a very short period before Latvian independence was restored.
Document 2: Russian Soviet Federative Socialist Republic: On June 12, 1990, the Congress of People's Deputies of the Republic adopted the Declaration of State Sovereignty of the Russian SFSR, which was the beginning of the "War of Laws", pitting the Soviet Union against the Russian Federation and other constituent republics.
Document 3: Russian Soviet Federative Socialist Republic: The RSFSR was established on November 7, 1917 (October Revolution) as a sovereign state. The first Constitution was adopted in 1918. In 1922 the Russian SFSR signed the Treaty on the Creation of the USSR.
Document 4: Latvian Soviet Socialist Republic: Following the Welles Declaration of July 23, 1940, the annexation of Latvia into the Soviet Union (USSR) on 5 August 1940 was not recognized as legitimate by the United States, the European Community, and recognition of it as the nominal fifteenth constituent republic of the USSR was withheld for five decades. Its territory was subsequently conquered by Nazi Germany in June -- July 1941, before being retaken by the Soviets in 1944 -- 1945. Nevertheless, Latvia continued to exist as a de jure independent country with a number of countries continued to recognize Latvian diplomats and consuls who still functioned in the name of their former governments.
Document 5: Estonian language: During the Perestroika era, The Law on the Status of the Estonian Language was adopted in January 1989. The collapse of the Soviet Union led to the restoration of Republic of Estonia's independence. Estonian went back to being the only state language in Estonia which in practice meant that use of Estonian was promoted while the use of Russian was discouraged.
Document 6: Ivars Godmanis: Ivars Godmanis (born 27 November 1951) is a Latvian politician who was Prime Minister of Latvia from 1990 to 1993 and again from 2007 to 2009. He was the first Prime Minister of Latvia after the country restored its independence from the Soviet Union.
Document 7: Russian Soviet Federative Socialist Republic: The Russian Soviet Federative Socialist Republic (Russian SFSR or RSFSR; Russian: Российская Советская Федеративная Социалистическая Республика, tr. Rossiyskaya Sovetskaya Federativnaya Sotsialisticheskaya Respublika  listen (help·info)) commonly referred to as Soviet Russia or simply as Russia, was a sovereign state in 1917–22, the largest, most populous, and most economically developed republic of the Soviet Union in 1922–91 and a sovereign part of the Soviet Union with its own legislation in 1990–91. The Republic comprised sixteen autonomous republics, five autonomous oblasts, ten autonomous okrugs, six krais, and forty oblasts. Russians formed the largest ethnic group. To the west it bordered Finland, Norway and Poland; and to the south, China, Mongolia and North Korea whilst bordering the Arctic Ocean to the north, the Pacific Ocean to the east and the Black sea and Caspian Sea to the south. Within the USSR, it bordered the Baltic republics (Lithuania, Latvia and Estonia), the Byelorussian SSR and the Ukrainian SSR to the west. To the south it bordered the Georgian, Azerbaijan and Kazakh SSRs.
Document 8: Russian Soviet Federative Socialist Republic: On December 8, 1991, at Viskuli near Brest (Belarus), the President of the Russian SFSR and the heads of Byelorussian SSR and Ukrainian SSR signed the "Agreement on the Establishment of the Commonwealth of Independent States" (known in media as Belavezha Accords). The document, consisting of a preamble and fourteen articles, stated that the Soviet Union ceased to exist as a subject of international law and geopolitical reality. However, based on the historical community of peoples, relations between them, given the bilateral treaties, the desire for a democratic rule of law, the intention to develop their relations based on mutual recognition and respect for state sovereignty, the parties agreed to the formation of the Commonwealth of Independent States. On December 12, the agreement was ratified by the Supreme Soviet of the Russian SFSR by an overwhelming majority: 188 votes for, 6 against, 7 abstentions. On the same day, the Supreme Soviet of the Russian SFSR denounced the Treaty on the Creation of the USSR and recalled all Russian deputies from the Supreme Soviet of the Soviet Union. The legality of this act is the subject of discussions because, according to the 1978 Constitution (Basic Law) of the Russian SFSR, the Russian Supreme Soviet had no right to do so. However, by this time the Soviet government had been rendered more or less impotent, and was in no position to object. Although the December 12 vote is sometimes reckoned as the moment that the RSFSR seceded from the collapsing Soviet Union, this is not the case. It appears that the RSFSR took the line that it was not possible to secede from an entity that no longer existed.
Document 9: History of Latvia: The First Latvian National Awakening began in the 1850s and continued to bear fruit after World War I when, after two years of struggle in the Latvian War of Independence, Latvia finally won sovereign independence, as recognised by Soviet Russia in 1920 and by the international community in 1921. The Constitution of Latvia was adopted in 1922. Political instability and effects of the Great Depression led to the May 15, 1934 coup d'état by Prime Minister Kārlis Ulmanis. Latvia's independence was interrupted in June -- July 1940, when the country was occupied and incorporated into the Soviet Union. In 1941 it was invaded and occupied by Nazi Germany, then reconquered by the Soviets in 1944 -- 45.
Document 10: Russian Soviet Federative Socialist Republic: On December 24, Yeltsin informed the Secretary-General of the United Nations that by agreement of the member states of the CIS Russian Federation would assume the membership of the Soviet Union in all UN organs (including permanent membership in the UN Security Council). Thus, Russia is considered to be an original member of the UN (since October 24, 1945) along with Ukraine (Ukrainian SSR) and Belarus (Byelorussian SSR). On December 25—just hours after Gorbachev resigned as president of the Soviet Union—the Russian SFSR was renamed the Russian Federation (Russia), reflecting that it was now a sovereign state with Yeltsin assuming the Presidency. The change was originally published on January 6, 1992 (Rossiyskaya Gazeta). According to law, during 1992, it was allowed to use the old name of the RSFSR for official business (forms, seals and stamps). The Russian Federation's Constitution (Fundamental Law) of 1978, though with the 1991–1992 Amendements, remained in effect until the 1993 Russian constitutional crisis.
Document 11: Dissolution of the Soviet Union: On June 14, 1987, about 5,000 people gathered again at Freedom Monument in Riga, and laid flowers to commemorate the anniversary of Stalin's mass deportation of Latvians in 1941. This was the first large demonstration in the Baltic republics to commemorate the anniversary of an event contrary to official Soviet history. The authorities did not crack down on demonstrators, which encouraged more and larger demonstrations throughout the Baltic States. The next major anniversary after the August 23 Molotov Pact demonstration was on November 18, the date of Latvia’s independence in 1918. On November 18, 1987, hundreds of police and civilian militiamen cordoned off the central square to prevent any demonstration at Freedom Monument, but thousands lined the streets of Riga in silent protest regardless.
Document 12: Russian Soviet Federative Socialist Republic: On December 30, 1922, with the creation of the Soviet Union, Russia became one of six republics within the federation of the Union of Soviet Socialist Republics. The final Soviet name for the republic, the Russian Soviet Federative Socialist Republic, was adopted in the Soviet Constitution of 1936. By that time, Soviet Russia had gained roughly the same borders of the old Tsardom of Russia before the Great Northern War of 1700.
Document 13: Russian Soviet Federative Socialist Republic: On June 12, 1990, the Congress of People's Deputies adopted the Declaration of State Sovereignty. On June 12, 1991, Boris Yeltsin was elected the first President. On December 8, 1991, heads of Russia, Ukraine and Belarus signed the Belavezha Accords. The agreement declared dissolution of the USSR by its founder states (i.e. denunciation of 1922 Treaty on the Creation of the USSR) and established the CIS. On December 12, the agreement was ratified by the Russian Parliament, therefore Russian SFSR denounced the Treaty on the Creation of the USSR and de facto declared Russia's independence from the USSR.
Document 14: Estonia: In 1989, during the "Singing Revolution", in a landmark demonstration for more independence, more than two million people formed a human chain stretching through Lithuania, Latvia and Estonia, called the Baltic Way. All three nations had similar experiences of occupation and similar aspirations for regaining independence. The Estonian Sovereignty Declaration was issued on 16 November 1988. On 20 August 1991, Estonia declared formal independence during the Soviet military coup attempt in Moscow, reconstituting the pre-1940 state. The Soviet Union recognised the independence of Estonia on 6 September 1991. The first country to diplomatically recognise Estonia's reclaimed independence was Iceland. The last units of the Russian army left on 31 August 1994.
Document 15: Russian Soviet Federative Socialist Republic: On December 25, 1991, the Russian SFSR was renamed the Russian Federation. On December 26, 1991, the USSR was self-dissolved by the Soviet of Nationalities, which by that time was the only functioning house of the Supreme Soviet (the other house, Soviet of the Union, had already lost the quorum after recall of its members by the union republics). After dissolution of the USSR, Russia declared that it assumed the rights and obligations of the dissolved central Soviet government, including UN membership.
ground_truth: 1920
sub_queries: What government was the Russian Federation fighting against during this period? Answer: the Soviet Union
when did latvia gain independence from the Soviet Union Answer: 1920