code: def stack_track_batch(
      tensors: List[torch.Tensor],
      pad_size_divisor: int = 0,
      pad_value: Union[int, float] = 0,
  ) -> torch.Tensor:
      """Stack multiple tensors to form a batch and pad the images to the max
      shape use the right bottom padding mode in these images. If
      ``pad_size_divisor > 0``, add padding to ensure the common height and width
      is divisible by ``pad_size_divisor``. The difference between this function
      and ``stack_batch`` in MMEngine is that this function can process batch
      sequence images with shape (N, T, C, H, W).
  
      Args:
          tensors (List[Tensor]): The input multiple tensors. each is a
              TCHW 4D-tensor. T denotes the number of key/reference frames.
          pad_size_divisor (int): If ``pad_size_divisor > 0``, add padding
              to ensure the common height and width is divisible by
              ``pad_size_divisor``. This depends on the model, and many
              models need a divisibility of 32. Defaults to 0
          pad_value (int, float): The padding value. Defaults to 0
  
      Returns:
         Tensor: The NTCHW 5D-tensor. N denotes the batch size.
      """
      assert isinstance(
          tensors, list
      ), f"Expected input type to be list, but got {type(tensors)}"
      assert len(set([tensor.ndim for tensor in tensors])) == 1, (
          f"Expected the dimensions of all tensors must be the same, "
          f"but got {[tensor.ndim for tensor in tensors]}"
      )
      assert tensors[0].ndim == 4, (
          f"Expected tensor dimension to be 4, "
          f"but got {tensors[0].ndim}"
      )
      assert len(set([tensor.shape[0] for tensor in tensors])) == 1, (
          f"Expected the channels of all tensors must be the same, "
          f"but got {[tensor.shape[0] for tensor in tensors]}"
      )
  
      tensor_sizes = [
          (tensor.shape[-2], tensor.shape[-1]) for tensor in tensors
      ]
      max_size = np.stack(tensor_sizes).max(0)
  
      if pad_size_divisor > 1:
          # the last two dims are H,W, both subject to divisibility requirement
          max_size = (
              (max_size + (pad_size_divisor - 1))
              // pad_size_divisor
              * pad_size_divisor
          )
  
      padded_samples = []
      for tensor in tensors:
          padding_size = [
              0,
              max_size[-1] - tensor.shape[-1],
              0,
              max_size[-2] - tensor.shape[-2],
          ]
          if sum(padding_size) == 0:
              padded_samples.append(tensor)
          else:
              padded_samples.append(
                  F.pad(tensor, padding_size, value=pad_value)
              )
  
      return torch.stack(padded_samples, dim=0)
  
file_path: mmdetection/mmdet/models/data_preprocessors/track_data_preprocessor.py
imports: from typing import Dict, List, Optional, Sequence, Union
  import numpy
  import torch
  import torch.nn.functional
  from mmengine.model.utils import stack_batch
  from mmdet.models.utils.misc import samplelist_boxtype2tensor
  from mmdet.registry import MODELS
  from mmdet.structures import TrackDataSample
  from mmdet.structures.mask import BitmapMasks
  from .data_preprocessor import DetDataPreprocessor
label_desc: Use image node_id 1 for calling a global function with example usage: stack_track_batch(tensors, pad_size_divisor, pad_value) and returns: torch