code: def test_insert_image(art_warning):
      file_path = os.path.join(
          os.getcwd(), "utils/data/backdoors/alert.png"
      )
      try:
          # test square
          image = insert_image(
              x=np.zeros((16, 16, 3)),
              backdoor_path=file_path,
              size=(8, 8),
              mode="RGB",
          )
          assert image.shape == (16, 16, 3)
          assert np.min(image) == 0
  
          # test non-square
          image = insert_image(
              x=np.zeros((20, 12, 3)),
              backdoor_path=file_path,
              size=(8, 8),
              mode="RGB",
          )
          assert image.shape == (20, 12, 3)
          assert np.min(image) == 0
  
          # test fixed location
          image = insert_image(
              x=np.zeros((16, 16, 3)),
              backdoor_path=file_path,
              size=(8, 8),
              random=False,
              x_shift=0,
              y_shift=0,
              mode="RGB",
          )
          assert image.shape == (16, 16, 3)
          assert np.min(image) == 0
  
          # test multiple
          image = insert_image(
              x=np.zeros((4, 16, 16, 3)),
              backdoor_path=file_path,
              size=(8, 8),
              mode="RGB",
          )
          assert image.shape == (4, 16, 16, 3)
          assert np.min(image) == 0
  
          # test invalid dimensions
          with pytest.raises(ValueError):
              _ = insert_image(
                  x=np.zeros((5, 5, 16, 16, 3)),
                  backdoor_path=file_path,
                  size=(8, 8),
                  mode="RGB",
              )
  
          # test backdoor is larger than image
          with pytest.raises(ValueError):
              _ = insert_image(
                  x=np.zeros((8, 8, 3)),
                  backdoor_path=file_path,
                  size=(10, 10),
                  mode="RGB",
              )
  
      except ARTTestException as e:
          art_warning(e)
  
file_path: adversarial-robustness-toolbox/tests/attacks/poison/test_image_perturbations.py
imports: from __future__ import absolute_import, division, print_function, unicode_literals
  import logging
  import os
  import numpy
  import pytest
  from art.attacks.poisoning.perturbations import add_single_bd, add_pattern_bd, insert_image
  from tests.utils import ARTTestException
label_desc: Use image node_id 3 for calling a global function with example usage: test_insert_image(art_warning) without return types