code: def test_black_box_with_label(
      art_warning, decision_tree_estimator, get_iris_dataset, model_type
  ):
      try:
          attack_feature = 2  # petal length
  
          # need to transform attacked feature into categorical
          def transform_feature(x):
              x[x > 0.5] = 2.0
              x[(x > 0.2) & (x <= 0.5)] = 1.0
              x[x <= 0.2] = 0.0
  
          values = [0.0, 1.0, 2.0]
  
          (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, attack_feature, 1
          )
          # only attacked feature
          x_train_feature = (
              x_train_iris[:, attack_feature].copy().reshape(-1, 1)
          )
          transform_feature(x_train_feature)
          # training data with attacked feature (after transformation)
          x_train = np.concatenate(
              (x_train_for_attack[:, :attack_feature], x_train_feature),
              axis=1,
          )
          x_train = np.concatenate(
              (x_train, x_train_for_attack[:, attack_feature:]), axis=1
          )
  
          # test data without attacked feature
          x_test_for_attack = np.delete(x_test_iris, attack_feature, 1)
          # only attacked feature
          x_test_feature = (
              x_test_iris[:, attack_feature].copy().reshape(-1, 1)
          )
          transform_feature(x_test_feature)
  
          classifier = decision_tree_estimator()
  
          attack = AttributeInferenceBlackBox(
              classifier,
              attack_feature=attack_feature,
              attack_model_type=model_type,
          )
          # get original model's predictions
          x_train_predictions = np.array(
              [
                  np.argmax(arr)
                  for arr in classifier.predict(x_train_iris)
              ]
          ).reshape(-1, 1)
          x_test_predictions = np.array(
              [
                  np.argmax(arr)
                  for arr in classifier.predict(x_test_iris)
              ]
          ).reshape(-1, 1)
          # train attack model
          attack.fit(x_train, y=y_train_iris)
          # infer attacked feature
          inferred_train = attack.infer(
              x_train_for_attack,
              y=y_train_iris,
              pred=x_train_predictions,
              values=values,
          )
          inferred_test = attack.infer(
              x_test_for_attack,
              y=y_test_iris,
              pred=x_test_predictions,
              values=values,
          )
          # check accuracy
          train_acc = np.sum(
              inferred_train == x_train_feature.reshape(1, -1)
          ) / len(inferred_train)
          test_acc = np.sum(
              inferred_test == x_test_feature.reshape(1, -1)
          ) / len(inferred_test)
          assert pytest.approx(0.8285, abs=0.35) == train_acc
          assert pytest.approx(0.8888, abs=0.35) == test_acc
          print(model_type, train_acc, 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
  import torch.nn
  import torch.optim
  from sklearn.tree import DecisionTreeClassifier
  from sklearn.preprocessing import StandardScaler, OrdinalEncoder
  from sklearn.compose import ColumnTransformer
  from sklearn.pipeline import Pipeline
  from art.attacks.inference.attribute_inference.black_box import AttributeInferenceBlackBox
  from art.estimators.classification.pytorch import PyTorchClassifier
  from art.estimators.estimator import BaseEstimator
  from art.estimators.classification import ClassifierMixin
  from art.estimators.classification.scikitlearn import ScikitlearnDecisionTreeClassifier, ScikitlearnClassifier
  from art.estimators.regression import ScikitlearnRegressor, RegressorMixin
  from art.utils import check_and_transform_label_format
  from tests.attacks.utils import backend_test_classifier_type_check_fail
  from tests.utils import ARTTestException
label_desc: Use image node_id 4 for calling a global function with example usage: test_black_box_with_label(art_warning, decision_tree_estimator, get_iris_dataset, model_type) without return types