code: def test_label_binarizer(setup):
      # one-class case defaults to negative label
      # For dense case:
      inp = ["pos", "pos", "pos", "pos"]
      lb = LabelBinarizer(sparse_output=False)
      expected = np.array([[0, 0, 0, 0]]).T
      got = lb.fit_transform(inp)
      assert_array_equal(lb.classes_, ["pos"])
      assert_array_equal(expected, got)
      assert_array_equal(lb.inverse_transform(got), inp)
  
      # For sparse case:
      lb = LabelBinarizer(sparse_output=True)
      got = lb.fit_transform(inp)
      assert got.issparse()
      assert_array_equal(lb.classes_, ["pos"])
      assert_array_equal(expected, got.fetch().toarray())
      assert_array_equal(lb.inverse_transform(got.todense()), inp)
  
      lb = LabelBinarizer(sparse_output=False)
      # two-class case
      inp = ["neg", "pos", "pos", "neg"]
      expected = np.array([[0, 1, 1, 0]]).T
      got = lb.fit_transform(inp)
      assert_array_equal(lb.classes_, ["neg", "pos"])
      assert_array_equal(expected, got)
  
      to_invert = np.array([[1, 0], [0, 1], [0, 1], [1, 0]])
      assert_array_equal(lb.inverse_transform(to_invert), inp)
  
      # multi-class case
      inp = ["spam", "ham", "eggs", "ham", "0"]
      expected = np.array(
          [
              [0, 0, 0, 1],
              [0, 0, 1, 0],
              [0, 1, 0, 0],
              [0, 0, 1, 0],
              [1, 0, 0, 0],
          ]
      )
      got = lb.fit_transform(inp)
      assert_array_equal(lb.classes_, ["0", "eggs", "ham", "spam"])
      assert_array_equal(expected, got)
      assert_array_equal(lb.inverse_transform(got), inp)
  
imports: import numpy
  import pytest
  import scipy.sparse
  from sklearn.preprocessing._label import _inverse_binarize_thresholding
  from sklearn.preprocessing._label import _inverse_binarize_multiclass
  from sklearn.utils._testing import assert_array_equal, ignore_warnings
  from sklearn.utils.multiclass import type_of_target
  from ....None import tensor
  from ..None import LabelBinarizer, label_binarize, LabelEncoder
label_desc: Use image node_id 1 for calling a global function with example usage: test_label_binarizer(setup) without return types