code: def _dataset_fn(
      dataloader, batch_fn, reduce_fn, *batch_fn_args, **batch_fn_kwargs
  ):
      """
      Applies `batch_fn` to each batch in `dataloader`, reducing the results using
      `reduce_fn`.  This is useful for computing Hessians and Hessian-vector
      products over an entire dataloader, and is used by both `NaiveInfluenceFunction`
      and `ArnoldiInfluenceFunction`.
      """
      _dataloader = iter(dataloader)
  
      def _reduce_fn(_result, _batch):
          return reduce_fn(
              _result,
              batch_fn(_batch, *batch_fn_args, **batch_fn_kwargs),
          )
  
      result = batch_fn(
          next(_dataloader), *batch_fn_args, **batch_fn_kwargs
      )
      return reduce(_reduce_fn, _dataloader, result)
  
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 33 for calling a global function with example usage: _dataset_fn(dataloader, batch_fn, reduce_fn) and returns: reduce, reduce_fn