code: def get_dataset_mean_std(
      dataset=None, img_size=None, output_div=255.0, dataset_name=None
  ):
      """
      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 dataset: pytorch Dataset
      :param img_size: 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.
      :param dataset_name: name of a well-known dataset to return (one of {'imagenet', 'general'})
  
      :return: (mean, std) as per-channel values ([r,g,b], [r,g,b])
      """
      if dataset_name in dataset_mean_std.keys():
          return dataset_mean_std[dataset_name]
      else:
          total = np.zeros(
              (3, (len(dataset) * img_size * img_size)), dtype=int
          )
          position = 0  # keep track of position in the total array
  
          for src, _ in tqdm(
              dataset, 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
  
file_path: pywick/pywick/data_stats.py
imports: import json
  import os
  import os.path
  import argparse
  import numpy
  from tqdm import tqdm
  from pywick.datasets.FolderDataset import FolderDataset, rgb_image_loader
label_desc: Use image node_id 1 for calling a global function with example usage: get_dataset_mean_std(dataset, img_size, output_div, dataset_name) and returns: dataset_mean_std, unknown,  unknown