class_docstr: ## Configurations
class_docstr_tok: ["#","#","Configurations"]
docstr: ### Generate noise
  
  This generates noise for each [generator block](index.html#generator_block)
docstr_tok: ["#","#","#","Generate","noise","This","generates","noise","for","each","[","generator","block","]","(","index.html","#","generator_block",")"]
code: def get_noise(self, batch_size: int):
      """
      ### Generate noise
  
      This generates noise for each [generator block](index.html#generator_block)
      """
      # List to store noise
      noise = []
      # Noise resolution starts from $4$
      resolution = 4
  
      # Generate noise for each generator block
      for i in range(self.n_gen_blocks):
          # The first block has only one $3 \times 3$ convolution
          if i == 0:
              n1 = None
          # Generate noise to add after the first convolution layer
          else:
              n1 = torch.randn(
                  batch_size,
                  1,
                  resolution,
                  resolution,
                  device=self.device,
              )
          # Generate noise to add after the second convolution layer
          n2 = torch.randn(
              batch_size, 1, resolution, resolution, device=self.device
          )
  
          # Add noise tensors to the list
          noise.append((n1, n2))
  
          # Next block has $2 \times$ resolution
          resolution *= 2
  
      # Return noise tensors
      return noise
  
imports: import math
  from pathlib import Path
  from typing import Iterator, Tuple
  import torch
  import torch.utils.data
  import torchvision
  from PIL import Image
  from labml import tracker, lab, monit, experiment
  from labml.configs import BaseConfigs
  from labml_helpers.device import DeviceConfigs
  from labml_helpers.train_valid import ModeState, hook_model_outputs
  from labml_nn.gan.stylegan import Discriminator, Generator, MappingNetwork, GradientPenalty, PathLengthPenalty
  from labml_nn.gan.wasserstein import DiscriminatorLoss, GeneratorLoss
  from labml_nn.utils import cycle_dataloader
label_desc: Use image node_id 3 for calling the Configs obj's underlying member method code with example usage: obj.get_noise(batch_size) and returns: noise