code: def uniform_temporal_subsample(
      x: torch.Tensor, num_samples: int, temporal_dim: int = -3
  ) -> torch.Tensor:
      """
      Uniformly subsamples num_samples indices from the temporal dimension of the video.
      When num_samples is larger than the size of temporal dimension of the video, it
      will sample frames based on nearest neighbor interpolation.
  
      Args:
          x (torch.Tensor): A video tensor with dimension larger than one with torch
              tensor type includes int, long, float, complex, etc.
          num_samples (int): The number of equispaced samples to be selected
          temporal_dim (int): dimension of temporal to perform temporal subsample.
  
      Returns:
          An x-like Tensor with subsampled temporal dimension.
      """
      t = x.shape[temporal_dim]
      assert num_samples > 0 and t > 0
      # Sample by nearest neighbor interpolation if num_samples > t.
      indices = torch.linspace(0, t - 1, num_samples)
      indices = torch.clamp(indices, 0, t - 1).long()
      return torch.index_select(x, temporal_dim, indices)
  
imports: import copy
  import math
  from typing import Tuple
  import numpy
  import torch
label_desc: Use image node_id 1 for calling a global function with example usage: uniform_temporal_subsample(x, num_samples, temporal_dim) and returns: torch