code: import torch
  import torch.nn as nn
  
  
  """
  usage
              z_rand = generate_noise([1,nzx,nzy], device=opt.device)
              z_rand = z_rand.expand(1,3,Z_opt.shape[2],Z_opt.shape[3])
              z_prev1 = 0.95*Z_opt +0.05*z_rand
  """
  
  
  def upsampling(im, sx, sy):
      m = nn.Upsample(size=[round(sx), round(sy)], mode='bilinear', align_corners=True)
      return m(im)
  
  
  def generate_noise(size, num_samp=1, device='cuda', type='gaussian', scale=1):
      if type == 'gaussian':
          noise = torch.randn(num_samp, size[0], round(size[1]/scale), round(size[2]/scale))
          noise = upsampling(noise, size[1], size[2])
      if type == 'gaussian_mixture':
          noise1 = torch.randn(num_samp, size[0], size[1], size[2]) + 5
          noise2 = torch.randn(num_samp, size[0], size[1], size[2])
          noise = noise1 + noise2
      if type == 'uniform':
          noise = torch.randn(num_samp, size[0], size[1], size[2])
      return noise
  
apis: torch.randn