code: def test_hierarchy_multi_level(self):
      hierarchy_multi_level_df = pd.DataFrame(
          {
              "Animal": [
                  "Cat",
                  "Cat",
                  "Dog",
                  "Dog",
                  "Dog",
                  "Osprey",
                  "Kite",
                  "Kite",
                  "Carp",
                  "Carp",
                  "Carp",
                  "Clownfish",
                  "Clownfish",
                  "Lizard",
                  "Snake",
                  "Snake",
              ],
              "target": [
                  1,
                  0,
                  1,
                  1,
                  1,
                  0,
                  0,
                  1,
                  0,
                  1,
                  0,
                  1,
                  0,
                  0,
                  0,
                  1,
              ],
          },
          columns=["Animal", "target"],
      )
      hierarchy_multi_level = {
          "Animal": {
              "Warm-Blooded": {
                  "Mammals": ("Cat", "Dog"),
                  "Birds": ("Osprey", "Kite"),
                  "Fish": ("Carp", "Clownfish"),
              },
              "Cold-Blooded": {
                  "Reptiles": ("Lizard"),
                  "Amphibians": ("Snake", "Frog"),
              },
          }
      }
  
      enc = encoders.TargetEncoder(
          verbose=1,
          smoothing=2,
          min_samples_leaf=2,
          hierarchy=hierarchy_multi_level,
          cols=["Animal"],
      )
      result = enc.fit_transform(
          hierarchy_multi_level_df, hierarchy_multi_level_df["target"]
      )
  
      values = result["Animal"].array
      self.assertAlmostEqual(0.6261, values[0], delta=1e-4)
      self.assertAlmostEqual(0.9065, values[2], delta=1e-4)
      self.assertAlmostEqual(0.2556, values[5], delta=1e-4)
      self.assertAlmostEqual(0.3680, values[8], delta=1e-4)
      self.assertAlmostEqual(0.4626, values[11], delta=1e-4)
      self.assertAlmostEqual(0.1535, values[13], delta=1e-4)
      self.assertAlmostEqual(0.4741, values[14], delta=1e-4)
  
imports: import pandas
  from unittest import TestCase
  import tests.helpers
  import numpy
  from category_encoders.datasets import load_postcodes, load_compass
  import category_encoders
label_desc: Use image node_id 17 for calling the TestTargetEncoder obj's underlying member method code with example usage: obj.test_hierarchy_multi_level() without return types