code: def batch_shuffle(items, batch_size):
      """Shuffles batches of fixed size within a sequence
  
      Arguments
      ---------
      items: sequence
          a tensor or an indexable sequence, such as a list
  
      batch_size: int
          the batch size
  
      Returns
      -------
      items: sequence
          the original items. If a tensor was passed, a tensor
          will be returned. Otherwise, it will return a list
      """
      batch_count = math.floor(len(items) / batch_size)
      batches = torch.randperm(batch_count)
      batch_idx = (
          batches.unsqueeze(-1).expand(batch_count, batch_size)
          * batch_size
      )
      batch_offset = torch.arange(batch_size).unsqueeze(0)
      batch_idx += batch_offset
      tail = torch.arange(batch_count * batch_size, len(items))
      batch_idx = torch.concat((batch_idx.flatten(), tail))
      if torch.is_tensor(items):
          result = items[batch_idx]
      else:
          result = [items[idx] for idx in batch_idx]
      return result
  
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 21 for calling a global function with example usage: batch_shuffle(items, batch_size) and returns: result