code: def _assert_compare_with_emb_patching(
      self,
      input: Union[Tensor, Tuple[Tensor, ...]],
      baseline: Union[Tensor, Tuple[Tensor, ...]],
      additional_args: Union[None, Tuple[Tensor, ...]],
      multiply_by_inputs: bool = True,
      multiple_emb: bool = False,
  ):
      model = BasicEmbeddingModel(nested_second_embedding=True)
      if multiple_emb:
          module_list: List[Module] = [
              model.embedding1,
              model.embedding2,
          ]
          lig = LayerIntegratedGradients(
              model,
              module_list,
              multiply_by_inputs=multiply_by_inputs,
          )
      else:
          lig = LayerIntegratedGradients(
              model,
              model.embedding1,
              multiply_by_inputs=multiply_by_inputs,
          )
  
      attributions, delta = lig.attribute(
          input,
          baselines=baseline,
          additional_forward_args=additional_args,
          return_convergence_delta=True,
      )
  
      # now let's interpret with standard integrated gradients and
      # the embeddings for monkey patching
      e1 = configure_interpretable_embedding_layer(model, "embedding1")
      e1_input_emb = e1.indices_to_embeddings(
          input[0] if multiple_emb else input
      )
      e1_baseline_emb = e1.indices_to_embeddings(
          baseline[0] if multiple_emb else baseline
      )
  
      input_emb = e1_input_emb
      baseline_emb = e1_baseline_emb
      e2 = None
      if multiple_emb:
          e2 = configure_interpretable_embedding_layer(
              model, "embedding2"
          )
          e2_input_emb = e2.indices_to_embeddings(*input[1:])
          e2_baseline_emb = e2.indices_to_embeddings(*baseline[1:])
  
          input_emb = (e1_input_emb, e2_input_emb)
          baseline_emb = (e1_baseline_emb, e2_baseline_emb)
  
      ig = IntegratedGradients(
          model, multiply_by_inputs=multiply_by_inputs
      )
      attributions_with_ig, delta_with_ig = ig.attribute(
          input_emb,
          baselines=baseline_emb,
          additional_forward_args=additional_args,
          target=0,
          return_convergence_delta=True,
      )
      remove_interpretable_embedding_layer(model, e1)
      if e2 is not None:
          remove_interpretable_embedding_layer(model, e2)
  
      self.assertEqual(
          isinstance(attributions_with_ig, tuple),
          isinstance(attributions, list),
      )
  
      self.assertTrue(
          isinstance(attributions_with_ig, tuple)
          if multiple_emb
          else not isinstance(attributions_with_ig, tuple)
      )
  
      # convert to tuple for comparison
      if not isinstance(attributions_with_ig, tuple):
          attributions = (attributions,)
          attributions_with_ig = (attributions_with_ig,)
      else:
          # convert list to tuple
          self.assertIsInstance(attributions, list)
          attributions = tuple(attributions)
  
      for attr_lig, attr_ig in zip(attributions, attributions_with_ig):
          self.assertEqual(
              cast(Tensor, attr_lig).shape, cast(Tensor, attr_ig).shape
          )
          assertTensorAlmostEqual(
              self, attr_lig, attr_ig, delta=0.05, mode="max"
          )
  
      if multiply_by_inputs:
          assertTensorAlmostEqual(
              self, delta, delta_with_ig, delta=0.05, mode="max"
          )
  
imports: from typing import Any, cast, List, Tuple, Union
  import torch
  from captum.attr._core.integrated_gradients import IntegratedGradients
  from captum.attr._core.layer.layer_activation import LayerActivation
  from captum.attr._core.layer.layer_conductance import LayerConductance
  from captum.attr._core.layer.layer_integrated_gradients import LayerIntegratedGradients
  from captum.attr._models.base import configure_interpretable_embedding_layer, remove_interpretable_embedding_layer
  from tests.helpers.basic import assertTensorAlmostEqual, assertTensorTuplesAlmostEqual, BaseTest
  from tests.helpers.basic_models import BasicEmbeddingModel, BasicModel_MultiLayer, BasicModel_MultiLayer_TrueMultiInput
  from torch import Tensor
  from torch.nn import Module
label_desc: Use image node_id 12 for calling the Test obj's underlying member method code with example usage: obj._assert_compare_with_emb_patching(input, baseline, additional_args, multiply_by_inputs, multiple_emb) without return types