code: def get_token_attributions(
      model: LudwigModel,
      feature_name: str,
      input_ids: torch.Tensor,
      token_attributions: torch.Tensor,
  ) -> List[List[Tuple[str, float]]]:
      """Convert token-level attributions to an array of token-attribution pairs of shape.
  
      [batch_size, sequence_length, 2].
  
      Args:
          model: The LudwigModel used to generate the attributions.
          feature_name: The name of the feature for which the attributions were generated.
          input_ids: The input ids of shape [batch_size, sequence_length].
          token_attributions: The token-level attributions of shape [batch_size, sequence_length].
  
      Returns:
          An array of token-attribution pairs of shape [batch_size, sequence_length, 2].
      """
      assert (
          input_ids.dtype == torch.int8
          or input_ids.dtype == torch.int16
          or input_ids.dtype == torch.int32
          or input_ids.dtype == torch.int64
      )
  
      # Normalize token-level attributions to visualize the relative importance of each token.
      norm = torch.linalg.norm(token_attributions, dim=1)
      # Safe divide by zero by setting the norm to 1 if the norm is 0.
      norm = torch.where(norm == 0, torch.ones_like(norm), norm)
      token_attributions = token_attributions / norm.unsqueeze(-1)
  
      # map input ids to input tokens via the vocabulary
      feature = model.training_set_metadata[feature_name]
      vocab = feature.get("idx2str", feature.get("word_idx2str"))
      idx2str = np.vectorize(lambda idx: vocab[idx])
      input_tokens = idx2str(input_ids)
  
      # add attribution to the input tokens
      tok_attrs = [
          list(zip(t, a))
          for t, a in zip(input_tokens, token_attributions.tolist())
      ]  # [batch_size, sequence_length, 2]
  
      return tok_attrs
  
imports: import copy
  import gc
  import logging
  from collections import defaultdict
  from dataclasses import dataclass
  from typing import Dict, List, Optional, Tuple
  import numpy
  import numpy.typing
  import pandas
  import torch
  from captum.attr import LayerIntegratedGradients, TokenReferenceBase
  from captum.attr._utils.input_layer_wrapper import InputIdentity
  from torch.autograd import Variable
  from tqdm import tqdm
  from ludwig.api import LudwigModel
  from ludwig.api_annotations import PublicAPI
  from ludwig.constants import BINARY, CATEGORY, DATE, IMAGE, INPUT_FEATURES, MINIMUM_BATCH_SIZE, NAME, NUMBER, PREPROCESSING, SEQUENCE, SET, TEXT, UNKNOWN_SYMBOL
  from ludwig.data.preprocessing import preprocess_for_prediction
  from ludwig.explain.explainer import Explainer
  from ludwig.explain.explanation import ExplanationsResult
  from ludwig.explain.util import get_pred_col, replace_layer_with_copy
  from ludwig.features.feature_utils import LudwigFeatureDict
  from ludwig.models.ecd import ECD
  from ludwig.utils.torch_utils import DEVICE
label_desc: Use image node_id 5 for calling a global function with example usage: get_token_attributions(model, feature_name, input_ids, token_attributions) and returns: tok_attrs