class_docstr: To implement the `influence` method, classes inheriting from `TracInCPBase` will
  separately implement the private `_self_influence`, `_get_k_most_influential`,
  and `_influence` methods. The public `influence` method is a wrapper for these
  private methods.
docstr: If `inputs` is not specified calculates the self influence
  scores for the training dataset `train_dataset`. Otherwise, computes
  self influence scores for the examples in `inputs`,
  which is either a single batch or a Pytorch `DataLoader` that yields
  batches. Therefore, in this case, the computed self influence scores
  are *not* for the examples in 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.
  
  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, 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. Therefore, the
              total number of (checkpoint, batch) combinations that need to be
              iterated over is
              (# of checkpoints x # of batches that `inputs` represents).
              If `show_progress` is True, the total progress of both the outer
              iteration over checkpoints and the inner iteration over batches is
              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
  
  Returns:
      self_influence_scores (Tensor): This is a 1D tensor containing the self
              influence scores of all examples in `inputs`, regardless of
              whether it represents a single batch or a `DataLoader` that yields
              batches.
docstr_tok: ["If","`","inputs","`","is","not","specified","calculates","the","self","influence","scores","for","the","training","dataset","`","train_dataset","`",".","Otherwise",",","computes","self","influence","scores","for","the","examples","in","`","inputs","`",",","which","is","either","a","single","batch","or","a","Pytorch","`","DataLoader","`","that","yields","batches",".","Therefore",",","in","this","case",",","the","computed","self","influence","scores","are","*","not","*","for","the","examples","in","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",".","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",",","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",".","Therefore",",","the","total","number","of","(","checkpoint",",","batch",")","combinations","that","need","to","be","iterated","over","is","(","#","of","checkpoints","x","#","of","batches","that","`","inputs","`","represents",")",".","If","`","show_progress","`","is","True",",","the","total","progress","of","both","the","outer","iteration","over","checkpoints","and","the","inner","iteration","over","batches","is","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","Returns",":","self_influence_scores","(","Tensor",")",":","This","is","a","1D","tensor","containing","the","self","influence","scores","of","all","examples","in","`","inputs","`",",","regardless","of","whether","it","represents","a","single","batch","or","a","`","DataLoader","`","that","yields","batches","."]
code: def self_influence(
      self,
      inputs: Optional[Union[Tuple[Any, ...], DataLoader]] = None,
      show_progress: bool = False,
  ) -> Tensor:
      """
      If `inputs` is not specified calculates the self influence
      scores for the training dataset `train_dataset`. Otherwise, computes
      self influence scores for the examples in `inputs`,
      which is either a single batch or a Pytorch `DataLoader` that yields
      batches. Therefore, in this case, the computed self influence scores
      are *not* for the examples in 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.
  
      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, 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. Therefore, the
                  total number of (checkpoint, batch) combinations that need to be
                  iterated over is
                  (# of checkpoints x # of batches that `inputs` represents).
                  If `show_progress` is True, the total progress of both the outer
                  iteration over checkpoints and the inner iteration over batches is
                  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
  
      Returns:
          self_influence_scores (Tensor): This is a 1D tensor containing the self
                  influence scores of all examples in `inputs`, regardless of
                  whether it represents a single batch or a `DataLoader` that yields
                  batches.
      """
      pass
  
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 2 for calling the TracInCPBase obj's underlying member method code with example usage: obj.self_influence(inputs, show_progress) without return types