code: def _self_influence_helper_intermediate_quantities_influence_function(
      influence_inst: "IntermediateQuantitiesInfluenceFunction",
      inputs_dataset: Optional[Union[Tuple[Any, ...], DataLoader]],
      show_progress: bool,
  ):
      """
      Helper function that computes self-influence scores for implementations of
      `NaiveInfluenceFunction` which implement the `compute_intermediate_quantities`
      method returning "embedding" vectors, so that the self-influence score of an
      example is the squared norm of its vector.
      """
  
      inputs_dataset = (
          inputs_dataset
          if inputs_dataset is not None
          else influence_inst.train_dataloader
      )
  
      # If `inputs_dataset` is not a `DataLoader`, turn it into one.
      inputs_dataset = _format_inputs_dataset(inputs_dataset)
  
      if show_progress:
          inputs_dataset = _progress_bar_constructor(
              influence_inst,
              inputs_dataset,
              "inputs_dataset",
              "self influence scores",
          )
  
      return torch.cat(
          [
              torch.sum(
                  influence_inst.compute_intermediate_quantities(
                      batch,
                      show_progress=False,
                  )
                  ** 2,
                  dim=1,
              )
              for batch in inputs_dataset
          ]
      )
  
imports: import warnings
  from functools import reduce
  from typing import Any, Callable, Iterable, List, NamedTuple, Optional, Tuple, TYPE_CHECKING, Union
  import torch
  import torch.nn
  from captum._utils.common import _get_module_from_name, _parse_version
  from captum._utils.gradient import _compute_jacobian_wrt_params, _compute_jacobian_wrt_params_with_sample_wise_trick
  from captum._utils.progress import progress
  from torch import Tensor
  from torch.nn import Module
  from torch.utils.data import DataLoader, Dataset
label_desc: Use image node_id 16 for calling a global function with example usage: _self_influence_helper_intermediate_quantities_influence_function(influence_inst, inputs_dataset, show_progress) and returns: torch