code: def test_search_model_versions(store):
      # create some model versions
      name = "test_for_search_MV"
      store.create_registered_model(name)
      run_id_1 = uuid.uuid4().hex
      run_id_2 = uuid.uuid4().hex
      run_id_3 = uuid.uuid4().hex
      mv1 = _create_model_version(
          store, name=name, source="A/B", run_id=run_id_1
      )
      assert mv1.version == 1
      mv2 = _create_model_version(
          store, name=name, source="A/C", run_id=run_id_2
      )
      assert mv2.version == 2
      mv3 = _create_model_version(
          store, name=name, source="A/D", run_id=run_id_2
      )
      assert mv3.version == 3
      mv4 = _create_model_version(
          store, name=name, source="A/D", run_id=run_id_3
      )
      assert mv4.version == 4
  
      def search_versions(filter_string):
          return [
              mvd.version
              for mvd in _search_model_versions(store, filter_string)
          ]
  
      # search using name should return all 4 versions
      assert set(search_versions(f"name='{name}'")) == {1, 2, 3, 4}
  
      # search using version
      assert set(search_versions("version_number=2")) == {2}
      assert set(search_versions("version_number<=3")) == {1, 2, 3}
  
      # search using run_id_1 should return version 1
      assert set(search_versions(f"run_id='{run_id_1}'")) == {1}
  
      # search using run_id_2 should return versions 2 and 3
      assert set(search_versions(f"run_id='{run_id_2}'")) == {2, 3}
  
      # search using the IN operator should return all versions
      assert set(
          search_versions(f"run_id IN ('{run_id_1}','{run_id_2}')")
      ) == {1, 2, 3}
  
      # search IN operator is case sensitive
      assert set(
          search_versions(
              f"run_id IN ('{run_id_1.upper()}','{run_id_2}')"
          )
      ) == {2, 3}
  
      # search IN operator with right-hand side value containing whitespaces
      assert set(
          search_versions(f"run_id IN ('{run_id_1}', '{run_id_2}')")
      ) == {1, 2, 3}
  
      # search IN operator with other conditions
      assert set(
          search_versions(
              f"version_number=2 AND run_id IN ('{run_id_1.upper()}','{run_id_2}')"
          )
      ) == {2}
  
      # search using the IN operator with bad lists should return exceptions
      with pytest.raises(
          MlflowException,
          match=(
              r"While parsing a list in the query, "
              r"expected string value, punctuation, or whitespace, "
              r"but got different type in list"
          ),
      ) as exception_context:
          search_versions("run_id IN (1,2,3)")
      assert exception_context.value.error_code == ErrorCode.Name(
          INVALID_PARAMETER_VALUE
      )
  
      assert set(
          search_versions(f"run_id LIKE '{run_id_2[:30]}%'")
      ) == {2, 3}
  
      assert set(
          search_versions(f"run_id ILIKE '{run_id_2[:30].upper()}%'")
      ) == {2, 3}
  
      # search using the IN operator with empty lists should return exceptions
      with pytest.raises(
          MlflowException,
          match=(
              r"While parsing a list in the query, "
              r"expected a non-empty list of string values, "
              r"but got empty list"
          ),
      ) as exception_context:
          search_versions("run_id IN ()")
      assert exception_context.value.error_code == ErrorCode.Name(
          INVALID_PARAMETER_VALUE
      )
  
      # search using an ill-formed IN operator correctly throws exception
      with pytest.raises(
          MlflowException, match=r"Invalid clause\(s\) in filter string"
      ) as exception_context:
          search_versions("run_id IN (")
      assert exception_context.value.error_code == ErrorCode.Name(
          INVALID_PARAMETER_VALUE
      )
  
      with pytest.raises(
          MlflowException, match=r"Invalid clause\(s\) in filter string"
      ) as exception_context:
          search_versions("run_id IN")
      assert exception_context.value.error_code == ErrorCode.Name(
          INVALID_PARAMETER_VALUE
      )
  
      with pytest.raises(
          MlflowException, match=r"Invalid clause\(s\) in filter string"
      ) as exception_context:
          search_versions("name LIKE")
      assert exception_context.value.error_code == ErrorCode.Name(
          INVALID_PARAMETER_VALUE
      )
  
      with pytest.raises(
          MlflowException,
          match=(
              r"While parsing a list in the query, "
              r"expected a non-empty list of string values, "
              r"but got ill-formed list"
          ),
      ) as exception_context:
          search_versions("run_id IN (,)")
      assert exception_context.value.error_code == ErrorCode.Name(
          INVALID_PARAMETER_VALUE
      )
  
      with pytest.raises(
          MlflowException,
          match=(
              r"While parsing a list in the query, "
              r"expected a non-empty list of string values, "
              r"but got ill-formed list"
          ),
      ) as exception_context:
          search_versions("run_id IN ('runid1',,'runid2')")
      assert exception_context.value.error_code == ErrorCode.Name(
          INVALID_PARAMETER_VALUE
      )
  
      # search using source_path "A/D" should return version 3 and 4
      assert set(search_versions("source_path = 'A/D'")) == {3, 4}
  
      # search using source_path "A" should not return anything
      assert len(search_versions("source_path = 'A'")) == 0
      assert len(search_versions("source_path = 'A/'")) == 0
      assert len(search_versions("source_path = ''")) == 0
  
      # delete mv4. search should not return version 4
      store.delete_model_version(name=mv4.name, version=mv4.version)
      assert set(search_versions("")) == {1, 2, 3}
  
      assert set(search_versions(None)) == {1, 2, 3}
  
      assert set(search_versions(f"name='{name}'")) == {1, 2, 3}
  
      store.transition_model_version_stage(
          name=mv1.name,
          version=mv1.version,
          stage="production",
          archive_existing_versions=False,
      )
  
      store.update_model_version(
          name=mv1.name,
          version=mv1.version,
          description="Online prediction model!",
      )
  
      mvds = store.search_model_versions(
          f"run_id = '{run_id_1}'", max_results=10
      )
      assert len(mvds) == 1
      assert isinstance(mvds[0], ModelVersion)
      assert mvds[0].current_stage == "Production"
      assert mvds[0].run_id == run_id_1
      assert mvds[0].source == "A/B"
      assert mvds[0].description == "Online prediction model!"
  
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 26 for calling a global function with example usage: test_search_model_versions(store) and returns: unknown