code: def get_dataset_mean_std(data_set, img_size=256, output_div=255.0):
      """
      Computes channel-wise mean and std of the dataset. The process is memory-intensive as the entire dataset must fit into memory.
      Therefore, each image is scaled down to img_size first (default: 256).
  
      Assumptions:
          1. dataset uses PIL to read images
          2. Images are in RGB format.
  
      :param data_set: (pytorch Dataset)
      :param img_size: (int):
          scale of images at which to compute mean/std (default: 256)
      :param output_div: (float `{1.0, 255.0}`):
          Image values are naturally in 0-255 value range so the returned output is divided by output_div. For example, if output_div = 255.0 then mean/std will be in 0-1 range.
  
      :return: (mean, std) as per-channel values ([r,g,b], [r,g,b])
      """
  
      total = np.zeros(
          (3, (len(data_set) * img_size * img_size)), dtype=int
      )
      position = 0  # keep track of position in the total array
  
      for src, _ in tqdm(
          data_set, ascii=True, desc="Process", unit="images"
      ):
          src = src.resize((img_size, img_size))  # resize to same size
          src = np.array(src)
  
          # reshape into correct shape
          src = src.reshape(img_size * img_size, 3)
          src = src.swapaxes(1, 0)
  
          # np.concatenate((a, b, c), axis=1)  # NOPE NOPE NOPE -- makes a memory re-allocation for every concatenate operation
  
          # -- In-place value substitution -- #
          place = img_size * img_size * position
          total[
              0 : src.shape[0], place : place + src.shape[1]
          ] = src  # copies the src data into the total position at specified index
  
          position = position + 1
  
      return total.mean(1) / output_div, total.std(1) / output_div
  
imports: import fnmatch
  import os
  import os.path
  import random
  import warnings
  import numpy
  import tqdm
label_desc: Use image node_id 16 for calling a global function with example usage: get_dataset_mean_std(data_set, img_size, output_div) and returns: unknown,  unknown