docstr: Compute mean and std of a single image and integrates it into global statistics
  Args:
      image: Input image (Must be HWC, with number of channels C equal to self.num_channels)
      mask: Optional mask to include only certain parts of image from statistics computation.
      Only non-zero elements will be included,
docstr_tok: ["Compute","mean","and","std","of","a","single","image","and","integrates","it","into","global","statistics","Args",":","image",":","Input","image","(","Must","be","HWC",",","with","number","of","channels","C","equal","to","self.num_channels",")","mask",":","Optional","mask","to","include","only","certain","parts","of","image","from","statistics","computation",".","Only","non-zero","elements","will","be","included",","]
code: def accumulate(
      self, image: np.ndarray, mask: Optional[np.ndarray] = None
  ) -> None:
      """
      Compute mean and std of a single image and integrates it into global statistics
      Args:
          image: Input image (Must be HWC, with number of channels C equal to self.num_channels)
          mask: Optional mask to include only certain parts of image from statistics computation.
          Only non-zero elements will be included,
      """
      if len(image.shape) == 2:
          image = np.expand_dims(image, axis=-1)
  
      if self.num_channels != image.shape[2]:
          raise RuntimeError(
              f"Number of channels in image must be {self.num_channels}, got {image.shape[2]}."
          )
      image = image.reshape((-1, self.num_channels))
  
      if mask is not None:
          mask = mask.reshape((mask.shape[0] * mask.shape[1]))
          image = image[mask, :]
  
          # In case the whole image is masked out, we exclude it entirely
          if len(image) == 0:
              return
  
      mean = np.mean(image, axis=0)
      std = np.std(image, axis=0)
  
      self.global_mean += np.squeeze(mean)
      self.global_var += np.squeeze(std) ** 2
      self.global_max = np.maximum(
          self.global_max, np.max(image, axis=0)
      )
      self.global_min = np.minimum(
          self.global_min, np.min(image, axis=0)
      )
      self.n_items += 1
  
imports: import numpy
  from typing import Optional, Tuple
label_desc: Use image node_id 3 for calling the DatasetMeanStdCalculator obj's underlying member method code with example usage: obj.accumulate(image, mask) without return types