code: def get_exp_kernel_similarity_function(
      distance_mode: str = "cosine", kernel_width: float = 1.0
  ) -> Callable:
      r"""
      This method constructs an appropriate similarity function to compute
      weights for perturbed sample in LIME. Distance between the original
      and perturbed inputs is computed based on the provided distance mode,
      and the distance is passed through an exponential kernel with given
      kernel width to convert to a range between 0 and 1.
  
      The callable returned can be provided as the similarity_fn for
      Lime or LimeBase.
  
      Args:
  
          distance_mode (str, optional): Distance mode can be either "cosine" or
                      "euclidean" corresponding to either cosine distance
                      or Euclidean distance respectively. Distance is computed
                      by flattening the original inputs and perturbed inputs
                      (concatenating tuples of inputs if necessary) and computing
                      distances between the resulting vectors.
                      Default: "cosine"
          kernel_width (float, optional):
                      Kernel width for exponential kernel applied to distance.
                      Default: 1.0
  
      Returns:
  
          *Callable*:
          - **similarity_fn** (*Callable*):
              Similarity function. This callable can be provided as the
              similarity_fn for Lime or LimeBase.
      """
  
      def default_exp_kernel(original_inp, perturbed_inp, __, **kwargs):
          flattened_original_inp = _flatten_tensor_or_tuple(
              original_inp
          ).float()
          flattened_perturbed_inp = _flatten_tensor_or_tuple(
              perturbed_inp
          ).float()
          if distance_mode == "cosine":
              cos_sim = CosineSimilarity(dim=0)
              distance = 1 - cos_sim(
                  flattened_original_inp, flattened_perturbed_inp
              )
          elif distance_mode == "euclidean":
              distance = torch.norm(
                  flattened_original_inp - flattened_perturbed_inp
              )
          else:
              raise ValueError(
                  "distance_mode must be either cosine or euclidean."
              )
          return math.exp(
              -1 * (distance**2) / (2 * (kernel_width**2))
          )
  
      return default_exp_kernel
  
imports: import inspect
  import math
  import typing
  import warnings
  from typing import Any, Callable, cast, List, Optional, Tuple, Union
  import torch
  from captum._utils.common import _expand_additional_forward_args, _expand_target, _flatten_tensor_or_tuple, _format_output, _format_tensor_into_tuples, _get_max_feature_index, _is_tuple, _reduce_list, _run_forward
  from captum._utils.models.linear_model import SkLearnLasso
  from captum._utils.models.model import Model
  from captum._utils.progress import progress
  from captum._utils.typing import BaselineType, Literal, TargetType, TensorOrTupleOfTensorsGeneric
  from captum.attr._utils.attribution import PerturbationAttribution
  from captum.attr._utils.batching import _batch_example_iterator
  from captum.attr._utils.common import _construct_default_feature_mask, _format_input_baseline
  from captum.log import log_usage
  from torch import Tensor
  from torch.nn import CosineSimilarity
  from torch.utils.data import DataLoader, TensorDataset
label_desc: Use image node_id 2 for calling a global function with example usage: get_exp_kernel_similarity_function(distance_mode, kernel_width) and returns: default_exp_kernel, math