code: def regen_perlin(perlin_mode, side_y, side_x, batch_size):
      if perlin_mode == "color":
          init = create_perlin_noise(
              [1.5**-i * 0.5 for i in range(12)],
              1,
              1,
              False,
              side_y,
              side_x,
          )
          init2 = create_perlin_noise(
              [1.5**-i * 0.5 for i in range(8)],
              4,
              4,
              False,
              side_y,
              side_x,
          )
      elif perlin_mode == "gray":
          init = create_perlin_noise(
              [1.5**-i * 0.5 for i in range(12)],
              1,
              1,
              True,
              side_y,
              side_x,
          )
          init2 = create_perlin_noise(
              [1.5**-i * 0.5 for i in range(8)],
              4,
              4,
              True,
              side_y,
              side_x,
          )
      else:
          init = create_perlin_noise(
              [1.5**-i * 0.5 for i in range(12)],
              1,
              1,
              False,
              side_y,
              side_x,
          )
          init2 = create_perlin_noise(
              [1.5**-i * 0.5 for i in range(8)],
              4,
              4,
              True,
              side_y,
              side_x,
          )
  
      init = (
          TF.to_tensor(init)
          .add(TF.to_tensor(init2))
          .divide(paddle.to_tensor(2.0))
          .unsqueeze(0)
          * 2
          - 1
      )
      del init2
      return init.expand([batch_size, -1, -1, -1])
  
file_path: PaddleHub/modules/image/text_to_image/disco_diffusion_clip_rn50/reverse_diffusion/model/perlin_noises.py
imports: import numpy
  import paddle
  import paddle.vision.transforms
  from PIL import Image
  from PIL import ImageOps
label_desc: Use image node_id 5 for calling a global function with example usage: regen_perlin(perlin_mode, side_y, side_x, batch_size) and returns: init