docstr: Computes self influence scores for the examples in `inputs`, which is
  either a single batch or a Pytorch `DataLoader` that yields batches.
  If `inputs` is not specified or `None` calculates self influence
  score for the training dataset `train_dataset`. Note that if `inputs`
  is a single batch, this will call `model` on that single batch, and if
  `inputs` yields batches, this will call `model` on each batch that is
  yielded. Therefore, please ensure that for both cases, the batch(es) that
  `model` is called with are not too large, so that there will not be an
  out-of-memory error.
  Internally, this computation requires iterating both over the batches in
  `inputs`, as well as different model checkpoints. There are two ways
  this iteration can be done. If `outer_loop_by_checkpoints` is False, the outer
  iteration will be over batches, and the inner iteration will be over
  checkpoints. This has the pro that displaying the progress of the computation
  is more intuitive, involving displaying the number of batches for which self
  influence scores have been computed. If `outer_loop_by_checkpoints` is True,
  the outer iteration will be over checkpoints, and the inner iteration will be
  over batches. This has the pro that the checkpoints do not need to be loaded
  for each batch. For large models, loading checkpoints can be time-intensive.
  
  Args:
      inputs (tuple or DataLoader, optional): This specifies the
              dataset for which self influence scores will be computed.
              Either a single tuple of any, or a `DataLoader`, where each
              batch yielded is a tuple of type 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 `batch[-1]` are the labels,
              if any. This is the same assumption made for each batch yielded
              by training dataset `train_dataset`. Please see documentation for
              the `train_dataset` argument to `TracInCP.__init__` for
              more details on the assumed structure of a batch. If not provided
              or `None`, self influence scores will be computed for training
              dataset `train_dataset`, which yields batches satisfying the
              above assumptions.
              Default: None.
      show_progress (bool, optional): Computation of self influence scores can
              take a long time if `inputs` represents many examples. If
              `show_progress`is true, the progress of this computation will be
              displayed. In more detail, if `outer_loop_by_checkpoints` is False,
              this computation will iterate over all batches in an outer loop.
              Thus if `show_progress` is True, the number of batches for which
              self influence scores have been computed will be displayed. If
              `outer_loop_by_checkpoints` is True, this computation will iterate
              over all checkpoints (provided as the `checkpoints` initialization
              argument) in an outer loop, and iterate over all batches that
              `inputs` represents in an inner loop. Thus if
              `show_progress` is True, the progress of both the outer
              iteration and the inner iterations will be displayed. To show
              progress, 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
      outer_loop_by_checkpoints (bool, optional): If performing an outer
              iteration over checkpoints; see method description for more
              details.
              Default: False
docstr_tok: ["Computes","self","influence","scores","for","the","examples","in","`","inputs","`",",","which","is","either","a","single","batch","or","a","Pytorch","`","DataLoader","`","that","yields","batches",".","If","`","inputs","`","is","not","specified","or","`","None","`","calculates","self","influence","score","for","the","training","dataset","`","train_dataset","`",".","Note","that","if","`","inputs","`","is","a","single","batch",",","this","will","call","`","model","`","on","that","single","batch",",","and","if","`","inputs","`","yields","batches",",","this","will","call","`","model","`","on","each","batch","that","is","yielded",".","Therefore",",","please","ensure","that","for","both","cases",",","the","batch","(","es",")","that","`","model","`","is","called","with","are","not","too","large",",","so","that","there","will","not","be","an","out-of-memory","error",".","Internally",",","this","computation","requires","iterating","both","over","the","batches","in","`","inputs","`",",","as","well","as","different","model","checkpoints",".","There","are","two","ways","this","iteration","can","be","done",".","If","`","outer_loop_by_checkpoints","`","is","False",",","the","outer","iteration","will","be","over","batches",",","and","the","inner","iteration","will","be","over","checkpoints",".","This","has","the","pro","that","displaying","the","progress","of","the","computation","is","more","intuitive",",","involving","displaying","the","number","of","batches","for","which","self","influence","scores","have","been","computed",".","If","`","outer_loop_by_checkpoints","`","is","True",",","the","outer","iteration","will","be","over","checkpoints",",","and","the","inner","iteration","will","be","over","batches",".","This","has","the","pro","that","the","checkpoints","do","not","need","to","be","loaded","for","each","batch",".","For","large","models",",","loading","checkpoints","can","be","time-intensive",".","Args",":","inputs","(","tuple","or","DataLoader",",","optional",")",":","This","specifies","the","dataset","for","which","self","influence","scores","will","be","computed",".","Either","a","single","tuple","of","any",",","or","a","`","DataLoader","`",",","where","each","batch","yielded","is","a","tuple","of","type","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","`","batch","[","-1","]","`","are","the","labels",",","if","any",".","This","is","the","same","assumption","made","for","each","batch","yielded","by","training","dataset","`","train_dataset","`",".","Please","see","documentation","for","the","`","train_dataset","`","argument","to","`","TracInCP.__init__","`","for","more","details","on","the","assumed","structure","of","a","batch",".","If","not","provided","or","`","None","`",",","self","influence","scores","will","be","computed","for","training","dataset","`","train_dataset","`",",","which","yields","batches","satisfying","the","above","assumptions",".","Default",":","None",".","show_progress","(","bool",",","optional",")",":","Computation","of","self","influence","scores","can","take","a","long","time","if","`","inputs","`","represents","many","examples",".","If","`","show_progress","`","is","true",",","the","progress","of","this","computation","will","be","displayed",".","In","more","detail",",","if","`","outer_loop_by_checkpoints","`","is","False",",","this","computation","will","iterate","over","all","batches","in","an","outer","loop",".","Thus","if","`","show_progress","`","is","True",",","the","number","of","batches","for","which","self","influence","scores","have","been","computed","will","be","displayed",".","If","`","outer_loop_by_checkpoints","`","is","True",",","this","computation","will","iterate","over","all","checkpoints","(","provided","as","the","`","checkpoints","`","initialization","argument",")","in","an","outer","loop",",","and","iterate","over","all","batches","that","`","inputs","`","represents","in","an","inner","loop",".","Thus","if","`","show_progress","`","is","True",",","the","progress","of","both","the","outer","iteration","and","the","inner","iterations","will","be","displayed",".","To","show","progress",",","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","outer_loop_by_checkpoints","(","bool",",","optional",")",":","If","performing","an","outer","iteration","over","checkpoints",";","see","method","description","for","more","details",".","Default",":","False"]
code: def self_influence(
      self,
      inputs: Optional[Union[Tuple[Any, ...], DataLoader]] = None,
      show_progress: bool = False,
      outer_loop_by_checkpoints: bool = False,
  ) -> Tensor:
      """
      Computes self influence scores for the examples in `inputs`, which is
      either a single batch or a Pytorch `DataLoader` that yields batches.
      If `inputs` is not specified or `None` calculates self influence
      score for the training dataset `train_dataset`. Note that if `inputs`
      is a single batch, this will call `model` on that single batch, and if
      `inputs` yields batches, this will call `model` on each batch that is
      yielded. Therefore, please ensure that for both cases, the batch(es) that
      `model` is called with are not too large, so that there will not be an
      out-of-memory error.
      Internally, this computation requires iterating both over the batches in
      `inputs`, as well as different model checkpoints. There are two ways
      this iteration can be done. If `outer_loop_by_checkpoints` is False, the outer
      iteration will be over batches, and the inner iteration will be over
      checkpoints. This has the pro that displaying the progress of the computation
      is more intuitive, involving displaying the number of batches for which self
      influence scores have been computed. If `outer_loop_by_checkpoints` is True,
      the outer iteration will be over checkpoints, and the inner iteration will be
      over batches. This has the pro that the checkpoints do not need to be loaded
      for each batch. For large models, loading checkpoints can be time-intensive.
  
      Args:
          inputs (tuple or DataLoader, optional): This specifies the
                  dataset for which self influence scores will be computed.
                  Either a single tuple of any, or a `DataLoader`, where each
                  batch yielded is a tuple of type 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 `batch[-1]` are the labels,
                  if any. This is the same assumption made for each batch yielded
                  by training dataset `train_dataset`. Please see documentation for
                  the `train_dataset` argument to `TracInCP.__init__` for
                  more details on the assumed structure of a batch. If not provided
                  or `None`, self influence scores will be computed for training
                  dataset `train_dataset`, which yields batches satisfying the
                  above assumptions.
                  Default: None.
          show_progress (bool, optional): Computation of self influence scores can
                  take a long time if `inputs` represents many examples. If
                  `show_progress`is true, the progress of this computation will be
                  displayed. In more detail, if `outer_loop_by_checkpoints` is False,
                  this computation will iterate over all batches in an outer loop.
                  Thus if `show_progress` is True, the number of batches for which
                  self influence scores have been computed will be displayed. If
                  `outer_loop_by_checkpoints` is True, this computation will iterate
                  over all checkpoints (provided as the `checkpoints` initialization
                  argument) in an outer loop, and iterate over all batches that
                  `inputs` represents in an inner loop. Thus if
                  `show_progress` is True, the progress of both the outer
                  iteration and the inner iterations will be displayed. To show
                  progress, 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
          outer_loop_by_checkpoints (bool, optional): If performing an outer
                  iteration over checkpoints; see method description for more
                  details.
                  Default: False
      """
      inputs = inputs if inputs is not None else self.train_dataloader
      if outer_loop_by_checkpoints:
          return self._self_influence_by_checkpoints(
              inputs, show_progress
          )
      return _self_influence_by_batches_helper(
          self._self_influence_by_checkpoints,
          self.get_name(),
          inputs,
          show_progress,
      )
  
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 11 for calling the TracInCP obj's underlying member method code with example usage: obj.self_influence(inputs, show_progress, outer_loop_by_checkpoints) and returns: _self_influence_by_batches_helper, self