class_docstr: This class provides functionality to store and load activation vectors
  generated for pre-defined neural network layers.
  It also provides functionality to check if activation vectors already
  exist in the manifold and other auxiliary functions.
  
  This class also defines a torch `Dataset`, representing Activation Vectors,
  which enables lazy access to activation vectors and layer stored in the manifold.
class_docstr_tok: ["This","class","provides","functionality","to","store","and","load","activation","vectors","generated","for","pre-defined","neural","network","layers",".","It","also","provides","functionality","to","check","if","activation","vectors","already","exist","in","the","manifold","and","other","auxiliary","functions",".","This","class","also","defines","a","torch","`","Dataset","`",",","representing","Activation","Vectors",",","which","enables","lazy","access","to","activation","vectors","and","layer","stored","in","the","manifold","."]
docstr: Computes layer activations for the given inputs and specified `layers`
  
  Args:
      path (str): The path where the activation vectors
              for the `layer` are stored.
      model (torch.nn.Module): An instance of pytorch model. This model should
              define all of its layers as attributes of the model.
      model_id (str): The name/version of the model for which layer activations
              are being computed and stored.
      layers (str or list[str]): The layer(s) for which the activation vectors
              are computed.
      inputs (Tensor or tuple[Tensor, ...]): Batch of examples for
              which influential instances are computed. They are passed to the
              input `model`. The first dimension in `inputs` tensor or tuple of
              tensors corresponds to the batch size.
      identifier (str or None): An optional identifier for the layer
              activations. Can be used to distinguish between activations for
              different training batches.
      num_id (str): An required string representing the batch number for which the
              activation vectors are computed
      additional_forward_args (Any, optional): Additional arguments that will be
              passed to `model` after inputs.
              Default: None
      load_from_disk (bool): Forces function to regenerate activations if False.
              Default: True
docstr_tok: ["Computes","layer","activations","for","the","given","inputs","and","specified","`","layers","`","Args",":","path","(","str",")",":","The","path","where","the","activation","vectors","for","the","`","layer","`","are","stored",".","model","(","torch.nn.Module",")",":","An","instance","of","pytorch","model",".","This","model","should","define","all","of","its","layers","as","attributes","of","the","model",".","model_id","(","str",")",":","The","name\/version","of","the","model","for","which","layer","activations","are","being","computed","and","stored",".","layers","(","str","or","list","[","str","]",")",":","The","layer","(","s",")","for","which","the","activation","vectors","are","computed",".","inputs","(","Tensor","or","tuple","[","Tensor",",","...","]",")",":","Batch","of","examples","for","which","influential","instances","are","computed",".","They","are","passed","to","the","input","`","model","`",".","The","first","dimension","in","`","inputs","`","tensor","or","tuple","of","tensors","corresponds","to","the","batch","size",".","identifier","(","str","or","None",")",":","An","optional","identifier","for","the","layer","activations",".","Can","be","used","to","distinguish","between","activations","for","different","training","batches",".","num_id","(","str",")",":","An","required","string","representing","the","batch","number","for","which","the","activation","vectors","are","computed","additional_forward_args","(","Any",",","optional",")",":","Additional","arguments","that","will","be","passed","to","`","model","`","after","inputs",".","Default",":","None","load_from_disk","(","bool",")",":","Forces","function","to","regenerate","activations","if","False",".","Default",":","True"]
code: def _compute_and_save_activations(
      path: str,
      model: Module,
      model_id: str,
      layers: Union[str, List[str]],
      inputs: Union[Tensor, Tuple[Tensor, ...]],
      identifier: str,
      num_id: str,
      additional_forward_args: Any = None,
      load_from_disk: bool = True,
  ) -> None:
      r"""
      Computes layer activations for the given inputs and specified `layers`
  
      Args:
          path (str): The path where the activation vectors
                  for the `layer` are stored.
          model (torch.nn.Module): An instance of pytorch model. This model should
                  define all of its layers as attributes of the model.
          model_id (str): The name/version of the model for which layer activations
                  are being computed and stored.
          layers (str or list[str]): The layer(s) for which the activation vectors
                  are computed.
          inputs (Tensor or tuple[Tensor, ...]): Batch of examples for
                  which influential instances are computed. They are passed to the
                  input `model`. The first dimension in `inputs` tensor or tuple of
                  tensors corresponds to the batch size.
          identifier (str or None): An optional identifier for the layer
                  activations. Can be used to distinguish between activations for
                  different training batches.
          num_id (str): An required string representing the batch number for which the
                  activation vectors are computed
          additional_forward_args (Any, optional): Additional arguments that will be
                  passed to `model` after inputs.
                  Default: None
          load_from_disk (bool): Forces function to regenerate activations if False.
                  Default: True
      """
      unsaved_layers = AV._manage_loading_layers(
          path,
          model_id,
          layers,
          load_from_disk,
          identifier,
          num_id,
      )
      layer_modules = [
          common._get_module_from_name(model, layer)
          for layer in unsaved_layers
      ]
      if len(unsaved_layers) > 0:
          layer_act = LayerActivation(model, layer_modules)
          new_activations = layer_act.attribute.__wrapped__(  # type: ignore
              layer_act, inputs, additional_forward_args
          )
          AV.save(
              path,
              model_id,
              identifier,
              unsaved_layers,
              new_activations,
              num_id,
          )
  
imports: import glob
  import os
  import re
  import warnings
  from typing import Any, List, Optional, Tuple, Union
  import captum._utils.common
  import torch
  from captum.attr import LayerActivation
  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 AV obj's underlying member method code with example usage: obj._compute_and_save_activations(path, model, model_id, layers, inputs, identifier, num_id, additional_forward_args, load_from_disk) without return types