code: def test_true_label_baseline_no_encoder_after_feature_slice(
      art_warning, get_iris_dataset, model_type
  ):
      try:
          orig_attack_feature = 1  # petal length
          new_attack_feature = slice(1, 4)  # petal length
  
          # need to transform attacked feature into categorical
          def transform_attacked_feature(x):
              x[x > 0.5] = 2.0
              x[(x > 0.2) & (x <= 0.5)] = 1.0
              x[x <= 0.2] = 0.0
  
          def transform_other_feature(x):
              x[x > 0.3] = 2.0
              x[(x > 0.2) & (x <= 0.3)] = 1.0
              x[x <= 0.2] = 0.0
              x[x == 2.0] = "A"
              x[x == 1.0] = "B"
              x[x == 0.0] = "C"
  
          (x_train_iris, y_train_iris), (
              x_test_iris,
              y_test_iris,
          ) = get_iris_dataset
  
          # training data without attacked feature
          x_train_for_attack = np.delete(
              x_train_iris, orig_attack_feature, 1
          )
          # transform attacked feature
          x_train_feature = x_train_iris[:, orig_attack_feature].copy()
          transform_attacked_feature(x_train_feature)
          x_train_feature = check_and_transform_label_format(
              x_train_feature, nb_classes=3, return_one_hot=True
          )
          # training data with attacked feature (after transformation)
          x_train = np.concatenate(
              (
                  x_train_for_attack[:, :orig_attack_feature],
                  x_train_feature,
              ),
              axis=1,
          )
          x_train = np.concatenate(
              (x_train, x_train_for_attack[:, orig_attack_feature:]),
              axis=1,
          )
  
          # transform other feature
          other_feature = (
              5  # was 3 before 1-hot encoding of attacked feature
          )
          x_without_feature = np.delete(x_train, other_feature, 1)
          x_other_feature = (
              x_train[:, other_feature]
              .copy()
              .reshape(-1, 1)
              .astype(object)
          )
          transform_other_feature(x_other_feature)
          # training data with other feature (after transformation)
          x_train = np.concatenate(
              (x_without_feature[:, :other_feature], x_other_feature),
              axis=1,
          )
          x_train = np.concatenate(
              (x_train, x_without_feature[:, other_feature:]), axis=1
          )
  
          new_other_feature = other_feature - 3
          x_train_for_attack_without_feature = np.delete(
              x_train_for_attack, new_other_feature, 1
          )
          x_train_for_attack = np.concatenate(
              (
                  x_train_for_attack_without_feature[
                      :, :new_other_feature
                  ],
                  x_other_feature,
              ),
              axis=1,
          )
          x_train_for_attack = np.concatenate(
              (
                  x_train_for_attack,
                  x_train_for_attack_without_feature[
                      :, new_other_feature:
                  ],
              ),
              axis=1,
          )
  
          # test data without attacked feature
          x_test_for_attack = np.delete(
              x_test_iris, orig_attack_feature, 1
          )
          # only attacked feature
          x_test_feature = x_test_iris[:, orig_attack_feature].copy()
          transform_attacked_feature(x_test_feature)
          x_test_feature = check_and_transform_label_format(
              x_test_feature, nb_classes=3, return_one_hot=True
          )
  
          # transform other feature
          x_test_without_feature = np.delete(
              x_test_for_attack, new_other_feature, 1
          )
          x_test_other_feature = (
              x_test_for_attack[:, new_other_feature]
              .copy()
              .reshape(-1, 1)
              .astype(object)
          )
          transform_other_feature(x_test_other_feature)
          # training data with other feature (after transformation)
          x_test_for_attack = np.concatenate(
              (
                  x_test_without_feature[:, :new_other_feature],
                  x_test_other_feature,
              ),
              axis=1,
          )
          x_test_for_attack = np.concatenate(
              (
                  x_test_for_attack,
                  x_test_without_feature[:, new_other_feature:],
              ),
              axis=1,
          )
  
          baseline_attack = AttributeInferenceBaselineTrueLabel(
              attack_feature=new_attack_feature,
              attack_model_type=model_type,
              non_numerical_features=[other_feature],
          )
          # train attack model
          baseline_attack.fit(x_train, y_train_iris)
          # infer attacked feature
          baseline_inferred_train = np.argmax(
              baseline_attack.infer(x_train_for_attack, y_train_iris),
              axis=1,
          )
          baseline_inferred_test = np.argmax(
              baseline_attack.infer(x_test_for_attack, y_test_iris),
              axis=1,
          )
          x_train_feature = np.argmax(x_train_feature, axis=1)
          x_test_feature = np.argmax(x_test_feature, axis=1)
          # check accuracy
          baseline_train_acc = np.sum(
              baseline_inferred_train == x_train_feature
          ) / len(baseline_inferred_train)
          baseline_test_acc = np.sum(
              baseline_inferred_test == x_test_feature
          ) / len(baseline_inferred_test)
  
          expected_train_acc = {
              "nn": 0.81,
              "rf": 0.98,
              "gb": 0.98,
              "lr": 0.81,
              "dt": 0.98,
              "knn": 0.85,
              "svm": 0.81,
          }
          expected_test_acc = {
              "nn": 0.88,
              "rf": 0.86,
              "gb": 0.8,
              "lr": 0.88,
              "dt": 0.84,
              "knn": 0.82,
              "svm": 0.88,
          }
  
          assert expected_train_acc[model_type] <= baseline_train_acc
          assert expected_test_acc[model_type] <= baseline_test_acc
  
      except ARTTestException as e:
          art_warning(e)
  
imports: from __future__ import absolute_import, division, print_function, unicode_literals
  import logging
  import pytest
  import numpy
  from sklearn.compose import ColumnTransformer
  from sklearn.preprocessing import OrdinalEncoder
  from art.attacks.inference.attribute_inference.true_label_baseline import AttributeInferenceBaselineTrueLabel
  from art.utils import check_and_transform_label_format
  from tests.utils import ARTTestException
label_desc: Use image node_id 10 for calling a global function with example usage: test_true_label_baseline_no_encoder_after_feature_slice(art_warning, get_iris_dataset, model_type) without return types