docstr: Args:
  
      inputs (Tuple, or DataLoader): Either a single tuple of any, or a
              `DataLoader`, where each batch yielded is a tuple of any. In
              either case, the tuple represents a single batch, where the last
              element is assumed to be the labels for the batch. That is,
              `model(*batch[0:-1])` produces the output for `model`, and
              and `batch[-1]` are the labels, if any. Here, `model` is model
              provided in initialization. This is the same assumption made for
              each batch yielded by training dataset `train_dataset`.
      k (int, optional): The number of proponents or opponents to return per test
              example.
              Default: 5
      proponents (bool, optional): Whether seeking proponents (`proponents=True`)
              or opponents (`proponents=False`)
              Default: True
      show_progress (bool, optional): To compute the proponents (or opponents)
              for the batch of examples, we perform computation for each batch in
              training dataset `train_dataset`, If `show_progress` is
              true, the progress of this computation will be displayed. In
              particular, the number of batches for which the computation has
              been performed will be displayed. It will try to use tqdm if
              available for advanced features (e.g. time estimation). Otherwise,
              it will fallback to a simple output of progress.
              Default: False
      aggregate (bool): Whether to return with the highest / lowest "aggregate"
              influence scores (see their definition in `influence`).
  
  Returns:
      (indices, influence_scores) (namedtuple): If `aggregate` is False,
              `indices` is a 2D tensor of shape `(input_size, k)`, where
              `input_size` is the number of examples in the test dataset. If
              computing proponents (resp. opponents), `indices[i][j]` is the
              index in training dataset `train_dataset` of the example with the
              `j`-th highest (resp. lowest) influence score (out of the examples
              in `train_dataset`) on the `i`-th example in the test dataset.
              `influence_scores` contains the corresponding influence scores. In
              particular, `influence_scores[i][j]` is the influence score of
              example `indices[i][j]` in `train_dataset` on example `i` in the
              test dataset represented by `inputs`. If `aggregate` is True,
              `indices` is a 2D tensor of shape `(1, k)`. If computing proponents
              (resp. opponents), `indices[0][j]` is the index in training dataset
              `train_dataset` of the example with the `j`-th highest (resp.
              lowest) aggregate influence score on the test dataset.
              `influence_scores` contains the corresponding aggregate influence
              scores. In particular, `influence_scores[0][j]` is the aggregate
              influence score of example `indices[0][j]` on the test dataset.
docstr_tok: ["Args",":","inputs","(","Tuple",",","or","DataLoader",")",":","Either","a","single","tuple","of","any",",","or","a","`","DataLoader","`",",","where","each","batch","yielded","is","a","tuple","of","any",".","In","either","case",",","the","tuple","represents","a","single","batch",",","where","the","last","element","is","assumed","to","be","the","labels","for","the","batch",".","That","is",",","`","model","(","*","batch","[","0",":","-1","]",")","`","produces","the","output","for","`","model","`",",","and","and","`","batch","[","-1","]","`","are","the","labels",",","if","any",".","Here",",","`","model","`","is","model","provided","in","initialization",".","This","is","the","same","assumption","made","for","each","batch","yielded","by","training","dataset","`","train_dataset","`",".","k","(","int",",","optional",")",":","The","number","of","proponents","or","opponents","to","return","per","test","example",".","Default",":","5","proponents","(","bool",",","optional",")",":","Whether","seeking","proponents","(","`","proponents=True","`",")","or","opponents","(","`","proponents=False","`",")","Default",":","True","show_progress","(","bool",",","optional",")",":","To","compute","the","proponents","(","or","opponents",")","for","the","batch","of","examples",",","we","perform","computation","for","each","batch","in","training","dataset","`","train_dataset","`",",","If","`","show_progress","`","is","true",",","the","progress","of","this","computation","will","be","displayed",".","In","particular",",","the","number","of","batches","for","which","the","computation","has","been","performed","will","be","displayed",".","It","will","try","to","use","tqdm","if","available","for","advanced","features","(","e.g",".","time","estimation",")",".","Otherwise",",","it","will","fallback","to","a","simple","output","of","progress",".","Default",":","False","aggregate","(","bool",")",":","Whether","to","return","with","the","highest","\/","lowest","``","aggregate","''","influence","scores","(","see","their","definition","in","`","influence","`",")",".","Returns",":","(","indices",",","influence_scores",")","(","namedtuple",")",":","If","`","aggregate","`","is","False",",","`","indices","`","is","a","2D","tensor","of","shape","`","(","input_size",",","k",")","`",",","where","`","input_size","`","is","the","number","of","examples","in","the","test","dataset",".","If","computing","proponents","(","resp",".","opponents",")",",","`","indices","[","i","]","[","j","]","`","is","the","index","in","training","dataset","`","train_dataset","`","of","the","example","with","the","`","j","`","-th","highest","(","resp",".","lowest",")","influence","score","(","out","of","the","examples","in","`","train_dataset","`",")","on","the","`","i","`","-th","example","in","the","test","dataset",".","`","influence_scores","`","contains","the","corresponding","influence","scores",".","In","particular",",","`","influence_scores","[","i","]","[","j","]","`","is","the","influence","score","of","example","`","indices","[","i","]","[","j","]","`","in","`","train_dataset","`","on","example","`","i","`","in","the","test","dataset","represented","by","`","inputs","`",".","If","`","aggregate","`","is","True",",","`","indices","`","is","a","2D","tensor","of","shape","`","(","1",",","k",")","`",".","If","computing","proponents","(","resp",".","opponents",")",",","`","indices","[","0","]","[","j","]","`","is","the","index","in","training","dataset","`","train_dataset","`","of","the","example","with","the","`","j","`","-th","highest","(","resp",".","lowest",")","aggregate","influence","score","on","the","test","dataset",".","`","influence_scores","`","contains","the","corresponding","aggregate","influence","scores",".","In","particular",",","`","influence_scores","[","0","]","[","j","]","`","is","the","aggregate","influence","score","of","example","`","indices","[","0","]","[","j","]","`","on","the","test","dataset","."]
code: def _get_k_most_influential(
      self,
      inputs: Union[Tuple[Any, ...], DataLoader],
      k: int = 5,
      proponents: bool = True,
      show_progress: bool = False,
      aggregate: bool = False,
  ) -> KMostInfluentialResults:
      r"""
      Args:
  
          inputs (Tuple, or DataLoader): Either a single tuple of any, or a
                  `DataLoader`, where each batch yielded is a tuple of any. In
                  either case, the tuple represents a single batch, where the last
                  element is assumed to be the labels for the batch. That is,
                  `model(*batch[0:-1])` produces the output for `model`, and
                  and `batch[-1]` are the labels, if any. Here, `model` is model
                  provided in initialization. This is the same assumption made for
                  each batch yielded by training dataset `train_dataset`.
          k (int, optional): The number of proponents or opponents to return per test
                  example.
                  Default: 5
          proponents (bool, optional): Whether seeking proponents (`proponents=True`)
                  or opponents (`proponents=False`)
                  Default: True
          show_progress (bool, optional): To compute the proponents (or opponents)
                  for the batch of examples, we perform computation for each batch in
                  training dataset `train_dataset`, If `show_progress` is
                  true, the progress of this computation will be displayed. In
                  particular, the number of batches for which the computation has
                  been performed will be displayed. It will try to use tqdm if
                  available for advanced features (e.g. time estimation). Otherwise,
                  it will fallback to a simple output of progress.
                  Default: False
          aggregate (bool): Whether to return with the highest / lowest "aggregate"
                  influence scores (see their definition in `influence`).
  
      Returns:
          (indices, influence_scores) (namedtuple): If `aggregate` is False,
                  `indices` is a 2D tensor of shape `(input_size, k)`, where
                  `input_size` is the number of examples in the test dataset. If
                  computing proponents (resp. opponents), `indices[i][j]` is the
                  index in training dataset `train_dataset` of the example with the
                  `j`-th highest (resp. lowest) influence score (out of the examples
                  in `train_dataset`) on the `i`-th example in the test dataset.
                  `influence_scores` contains the corresponding influence scores. In
                  particular, `influence_scores[i][j]` is the influence score of
                  example `indices[i][j]` in `train_dataset` on example `i` in the
                  test dataset represented by `inputs`. If `aggregate` is True,
                  `indices` is a 2D tensor of shape `(1, k)`. If computing proponents
                  (resp. opponents), `indices[0][j]` is the index in training dataset
                  `train_dataset` of the example with the `j`-th highest (resp.
                  lowest) aggregate influence score on the test dataset.
                  `influence_scores` contains the corresponding aggregate influence
                  scores. In particular, `influence_scores[0][j]` is the aggregate
                  influence score of example `indices[0][j]` on the test dataset.
      """
      # If `inputs` is not a `DataLoader`, turn it into one.
      inputs = _format_inputs_dataset(inputs)
  
      desc = (
          None
          if not show_progress
          else (
              (
                  f"Using {self.get_name()} to perform computation for "
                  f'getting {"proponents" if proponents else "opponents"}. '
                  "Processing training batches"
              )
          )
      )
  
      # create list of the outputs of `_basic_computation_tracincp`, for each
      # checkpoint, which are jacobians
      inputs_checkpoint_jacobians = self._get_checkpoint_jacobians(
          inputs, aggregate, self.test_loss_fn
      )
  
      return KMostInfluentialResults(
          *_get_k_most_influential_helper(
              self.train_dataloader,
              self._influence_batch_tracincp,
              inputs_checkpoint_jacobians,
              k,
              proponents,
              show_progress,
              desc,
          )
      )
  
imports: import glob
  import warnings
  from abc import abstractmethod
  from os.path import join
  from typing import Any, Callable, Iterator, List, Optional, Tuple, Type, Union
  import torch
  from captum._utils.av import AV
  from captum._utils.common import _parse_version
  from captum._utils.progress import NullProgress, progress
  from captum.influence._core.influence import DataInfluence
  from captum.influence._utils.common import _check_loss_fn, _compute_jacobian_sample_wise_grads_per_batch, _format_inputs_dataset, _get_k_most_influential_helper, _gradient_dot_product, _influence_route_to_helpers, _load_flexible_state_dict, _self_influence_by_batches_helper, _set_active_parameters, KMostInfluentialResults
  from captum.log import log_usage
  from torch import Tensor
  from torch.nn import Module
  from torch.utils.data import DataLoader, Dataset
label_desc: Use image node_id 9 for calling the TracInCP obj's underlying member method code with example usage: obj._get_k_most_influential(inputs, k, proponents, show_progress, aggregate) and returns: KMostInfluentialResults