code: def gen_batch(inputs, batch_size, dynamic_batch=False, shuffle=False):
      """Data iterator in batch.
  
      Args:
          inputs: np.ndarray, [len_seq, n_frame, n_route, C_0], standard sequence units.
          batch_size: int, size of batch.
          dynamic_batch: bool, whether changes the batch size in the last batch
              if its length is less than the default.
          shuffle: bool, whether shuffle the batches.
      """
      len_inputs = len(inputs)
  
      if shuffle:
          idx = np.arange(len_inputs)
          np.random.shuffle(idx)
  
      for start_idx in range(0, len_inputs, batch_size):
          end_idx = start_idx + batch_size
          if end_idx > len_inputs:
              if dynamic_batch:
                  end_idx = len_inputs
              else:
                  break
          if shuffle:
              slide = idx[start_idx:end_idx]
          else:
              slide = slice(start_idx, end_idx)
  
          yield inputs[slide]
  
file_path: PGL/legacy/examples/stgcn/data_loader/data_utils.py
imports: import numpy
  import pandas
  from utils.math_utils import z_score
label_desc: Use image node_id 6 for calling a global function with example usage: gen_batch(inputs, batch_size, dynamic_batch, shuffle) without return types