code: def test_transition_model_version_stage_when_archive_existing_versions_is_true(
      store,
  ):
      name = "model"
      store.create_registered_model(name)
      mv1 = _create_model_version(store, name)
      mv2 = _create_model_version(store, name)
      mv3 = _create_model_version(store, name)
  
      msg = (
          r"Model version transition cannot archive existing model versions "
          r"because .+ is not an Active stage"
      )
  
      # test that when `archive_existing_versions` is True, transitioning a model version
      # to the inactive stages ("Archived" and "None") throws.
      for stage in ["Archived", "None"]:
          with pytest.raises(MlflowException, match=msg):
              store.transition_model_version_stage(
                  name, mv1.version, stage, True
              )
  
      store.transition_model_version_stage(
          name, mv1.version, "Staging", False
      )
      store.transition_model_version_stage(
          name, mv2.version, "Production", False
      )
      store.transition_model_version_stage(
          name, mv3.version, "Staging", True
      )
  
      mvd1 = store.get_model_version(name=name, version=mv1.version)
      mvd2 = store.get_model_version(name=name, version=mv2.version)
      mvd3 = store.get_model_version(name=name, version=mv3.version)
  
      assert mvd1.current_stage == "Archived"
      assert mvd2.current_stage == "Production"
      assert mvd3.current_stage == "Staging"
      assert mvd1.last_updated_timestamp == mvd3.last_updated_timestamp
  
      store.transition_model_version_stage(
          name, mv3.version, "Production", True
      )
  
      mvd1 = store.get_model_version(name=name, version=mv1.version)
      mvd2 = store.get_model_version(name=name, version=mv2.version)
      mvd3 = store.get_model_version(name=name, version=mv3.version)
  
      assert mvd1.current_stage == "Archived"
      assert mvd2.current_stage == "Archived"
      assert mvd3.current_stage == "Production"
      assert mvd2.last_updated_timestamp == mvd3.last_updated_timestamp
  
      for uncanonical_stage_name in ["STAGING", "staging", "StAgInG"]:
          store.transition_model_version_stage(
              mv1.name, mv1.version, "Staging", False
          )
          store.transition_model_version_stage(
              mv2.name, mv2.version, "None", False
          )
  
          # stage names are case-insensitive and auto-corrected to system stage names
          store.transition_model_version_stage(
              mv2.name, mv2.version, uncanonical_stage_name, True
          )
  
          mvd1 = store.get_model_version(
              name=mv1.name, version=mv1.version
          )
          mvd2 = store.get_model_version(
              name=mv2.name, version=mv2.version
          )
          assert mvd1.current_stage == "Archived"
          assert mvd2.current_stage == "Staging"
  
imports: import time
  import uuid
  from typing import List, NamedTuple
  from unittest import mock
  import pytest
  from mlflow.entities.model_registry import ModelVersion, ModelVersionTag, RegisteredModelTag
  from mlflow.exceptions import MlflowException
  from mlflow.protos.databricks_pb2 import INVALID_PARAMETER_VALUE, RESOURCE_DOES_NOT_EXIST, ErrorCode
  from mlflow.store.model_registry.file_store import FileStore
  from mlflow.utils.file_utils import path_to_local_file_uri, write_yaml
  from mlflow.utils.time import get_current_time_millis
  from tests.helper_functions import random_int, random_str
label_desc: Use image node_id 23 for calling a global function with example usage: test_transition_model_version_stage_when_archive_existing_versions_is_true(store) without return types