code: def batch_pad_right(tensors: list, mode="constant", value=0):
      """Given a list of torch tensors it batches them together by padding to the right
      on each dimension in order to get same length for all.
  
      Parameters
      ----------
      tensors : list
          List of tensor we wish to pad together.
      mode : str
          Padding mode see torch.nn.functional.pad documentation.
      value : float
          Padding value see torch.nn.functional.pad documentation.
  
      Returns
      -------
      tensor : torch.Tensor
          Padded tensor.
      valid_vals : list
          List containing proportion for each dimension of original, non-padded values.
  
      """
  
      if not len(tensors):
          raise IndexError("Tensors list must not be empty")
  
      if len(tensors) == 1:
          # if there is only one tensor in the batch we simply unsqueeze it.
          return tensors[0].unsqueeze(0), torch.tensor([1.0])
  
      if not (
          all(
              [
                  tensors[i].ndim == tensors[0].ndim
                  for i in range(1, len(tensors))
              ]
          )
      ):
          raise IndexError(
              "All tensors must have same number of dimensions"
          )
  
      # FIXME we limit the support here: we allow padding of only the first dimension
      # need to remove this when feat extraction is updated to handle multichannel.
      max_shape = []
      for dim in range(tensors[0].ndim):
          if dim != 0:
              if not all(
                  [
                      x.shape[dim] == tensors[0].shape[dim]
                      for x in tensors[1:]
                  ]
              ):
                  raise EnvironmentError(
                      "Tensors should have same dimensions except for the first one"
                  )
          max_shape.append(max([x.shape[dim] for x in tensors]))
  
      batched = []
      valid = []
      for t in tensors:
          # for each tensor we apply pad_right_to
          padded, valid_percent = pad_right_to(
              t, max_shape, mode=mode, value=value
          )
          batched.append(padded)
          valid.append(valid_percent[0])
  
      batched = torch.stack(batched)
  
      return batched, torch.tensor(valid)
  
imports: import math
  import os
  import re
  import csv
  import shutil
  import urllib.request
  import collections.abc
  import torch
  import tqdm
  import pathlib
  import speechbrain
  from numbers import Number
label_desc: Use image node_id 10 for calling a global function with example usage: batch_pad_right(tensors, mode, value) and returns: batched,  torch, tensors,  torch