code: def _lime_test_assert(
      self,
      model: Callable,
      test_input: TensorOrTupleOfTensorsGeneric,
      expected_attr,
      expected_coefs_only=None,
      feature_mask: Union[None, TensorOrTupleOfTensorsGeneric] = None,
      additional_input: Any = None,
      perturbations_per_eval: Tuple[int, ...] = (1,),
      baselines: BaselineType = None,
      target: Union[None, int] = 0,
      n_samples: int = 100,
      delta: float = 1.0,
      batch_attr: bool = False,
      test_generator: bool = False,
      show_progress: bool = False,
      interpretable_model: Optional[Model] = None,
  ) -> None:
      for batch_size in perturbations_per_eval:
          lime = Lime(
              model,
              similarity_func=get_exp_kernel_similarity_function(
                  "cosine", 10.0
              ),
              interpretable_model=interpretable_model
              if interpretable_model
              else SkLearnLasso(alpha=1.0),
          )
          attributions = lime.attribute(
              test_input,
              target=target,
              feature_mask=feature_mask,
              additional_forward_args=additional_input,
              baselines=baselines,
              perturbations_per_eval=batch_size,
              n_samples=n_samples,
              show_progress=show_progress,
          )
          assertTensorTuplesAlmostEqual(
              self, attributions, expected_attr, delta=delta, mode="max"
          )
          if expected_coefs_only is not None:
              # Test with return_input_shape = False
              attributions = lime.attribute(
                  test_input,
                  target=target,
                  feature_mask=feature_mask,
                  additional_forward_args=additional_input,
                  baselines=baselines,
                  perturbations_per_eval=batch_size,
                  n_samples=n_samples,
                  return_input_shape=False,
                  show_progress=show_progress,
              )
              assertTensorAlmostEqual(
                  self,
                  attributions,
                  expected_coefs_only,
                  delta=delta,
                  mode="max",
              )
  
              lime_alt = LimeBase(
                  model,
                  interpretable_model
                  if interpretable_model
                  else SkLearnLasso(alpha=1.0),
                  get_exp_kernel_similarity_function(
                      "euclidean", 1000.0
                  ),
                  alt_perturb_generator
                  if test_generator
                  else alt_perturb_func,
                  False,
                  None,
                  alt_to_interp_rep,
              )
  
              # Test with equivalent sampling in original input space
              formatted_inputs, baselines = _format_input_baseline(
                  test_input, baselines
              )
              if feature_mask is None:
                  (
                      formatted_feature_mask,
                      num_interp_features,
                  ) = _construct_default_feature_mask(formatted_inputs)
              else:
                  formatted_feature_mask = _format_tensor_into_tuples(
                      feature_mask
                  )
                  num_interp_features = int(
                      max(
                          torch.max(single_mask).item()
                          for single_mask in feature_mask
                          if single_mask.numel()
                      )
                      + 1
                  )
              if batch_attr:
                  attributions = lime_alt.attribute(
                      test_input,
                      target=target,
                      feature_mask=formatted_feature_mask
                      if isinstance(test_input, tuple)
                      else formatted_feature_mask[0],
                      additional_forward_args=additional_input,
                      baselines=baselines,
                      perturbations_per_eval=batch_size,
                      n_samples=n_samples,
                      num_interp_features=num_interp_features,
                      show_progress=show_progress,
                  )
                  assertTensorAlmostEqual(
                      self,
                      attributions,
                      expected_coefs_only,
                      delta=delta,
                      mode="max",
                  )
                  return
  
              bsz = formatted_inputs[0].shape[0]
              for (
                  curr_inps,
                  curr_target,
                  curr_additional_args,
                  curr_baselines,
                  curr_feature_mask,
                  expected_coef_single,
              ) in _batch_example_iterator(
                  bsz,
                  test_input,
                  target,
                  additional_input,
                  baselines
                  if isinstance(test_input, tuple)
                  else baselines[0],
                  formatted_feature_mask
                  if isinstance(test_input, tuple)
                  else formatted_feature_mask[0],
                  expected_coefs_only,
              ):
                  attributions = lime_alt.attribute(
                      curr_inps,
                      target=curr_target,
                      feature_mask=curr_feature_mask,
                      additional_forward_args=curr_additional_args,
                      baselines=curr_baselines,
                      perturbations_per_eval=batch_size,
                      n_samples=n_samples,
                      num_interp_features=num_interp_features,
                      show_progress=show_progress,
                  )
                  assertTensorAlmostEqual(
                      self,
                      attributions,
                      expected_coef_single,
                      delta=delta,
                      mode="max",
                  )
  
imports: import io
  import unittest
  import unittest.mock
  from functools import partial
  from typing import Any, Callable, Generator, List, Optional, Tuple, Union
  import torch
  from captum._utils.models.linear_model import SGDLasso, SkLearnLasso
  from captum._utils.models.model import Model
  from captum._utils.typing import BaselineType, TensorOrTupleOfTensorsGeneric
  from captum.attr._core.lime import get_exp_kernel_similarity_function, Lime, LimeBase
  from captum.attr._utils.batching import _batch_example_iterator
  from captum.attr._utils.common import _construct_default_feature_mask, _format_input_baseline, _format_tensor_into_tuples
  from tests.helpers.basic import assertTensorAlmostEqual, assertTensorTuplesAlmostEqual, BaseTest
  from tests.helpers.basic_models import BasicLinearModel, BasicModel_MultiLayer, BasicModel_MultiLayer_MultiInput, BasicModelBoolInput
  from torch import Tensor
label_desc: Use image node_id 26 for calling the Test obj's underlying member method code with example usage: obj._lime_test_assert(model, test_input, expected_attr, expected_coefs_only, feature_mask, additional_input, perturbations_per_eval, baselines, target, n_samples, delta, batch_attr, test_generator, show_progress, interpretable_model) without return types