code: def test_tovw():
      x = np.array([[1.2, 3.4, 5.6, 1.0, 10], [7.8, 9.10, 11, 0, 20]])
      y = np.array([2, 0])
      w = [1, 2]
  
      expected = [
          "1 1 | 0:1.2 1:3.4 2:5.6 3:1 4:10",
          "-1 2 | 0:7.8 1:9.1 2:11 4:20",
      ]
  
      assert (
          tovw(x=x, y=y, sample_weight=w, convert_labels=True)
          == expected
      )
      assert (
          tovw(
              x=csr_matrix(x), y=y, sample_weight=w, convert_labels=True
          )
          == expected
      )
  
imports: from collections import namedtuple
  import os
  import numpy
  from packaging import version
  import pandas
  import pytest
  from scipy.sparse import csr_matrix
  from sklearn import datasets, __version__
  from sklearn.model_selection import KFold
  from sklearn.utils.estimator_checks import check_estimator
  from vowpalwabbit.sklearn import VW, VWClassifier, VWRegressor, tovw, VWMultiClassifier, VWRegressor
label_desc: Use image node_id 2 for calling a global function with example usage: test_tovw() without return types