code: def _get_batch_size(*, module: nn.Module, batch_dim: int) -> int:
      """
      Computes and returns the maximum batch size which is the maximum of the dimension values
      along 'batch_dim' axis over module.activations, where module.activations is
      a list.
  
      Args:
          module: input module
          batch_dim: batch dimension
  
      Returns:
          Maximum sequence length in a batch
      """
      max_batch_len = 0
      for out in module.activations:
          # out is typically a tuple of one element (x)
          # for embedding bag, it is a tuple of two elements (x, offsets)
          # where len(offsets) = batch_size
          if out[-1].shape[batch_dim] > max_batch_len:
              max_batch_len = out[-1].shape[batch_dim]
  
      return max_batch_len
  
imports: from __future__ import annotations
  import logging
  import warnings
  from functools import partial
  from typing import Iterable, List, Tuple
  import torch
  import torch.nn
  from opacus.grad_sample.functorch import ft_compute_per_sample_gradient, prepare_layer
  from opacus.grad_sample.gsm_base import AbstractGradSampleModule
  from opacus.layers.dp_rnn import DPGRU, DPLSTM, DPRNN, RNNLinear
  from opacus.utils.module_utils import has_trainable_params, requires_grad, trainable_modules, trainable_parameters
label_desc: Use image node_id 3 for calling a global function with example usage: _get_batch_size() and returns: max_batch_len