class_docstr: Anomaly generator of the DSR model. The anomaly is generated using a Perlin
  noise generator on the two quantized representations of an image. This generator
  is only used during the second phase of training! The third phase requires generating
  smudges over the input images.
  
  Args:
      p_anomalous (float, optional): Probability to generate an anomalous image.
docstr: Generate an anomalous mask.
  
  Args:
      height (int): Height of generated mask.
      width (int): Width of generated mask.
  
  Returns:
      Tensor: Generated mask.
docstr_tok: ["Generate","an","anomalous","mask",".","Args",":","height","(","int",")",":","Height","of","generated","mask",".","width","(","int",")",":","Width","of","generated","mask",".","Returns",":","Tensor",":","Generated","mask","."]
code: def generate_anomaly(self, height: int, width: int) -> Tensor:
      """Generate an anomalous mask.
  
      Args:
          height (int): Height of generated mask.
          width (int): Width of generated mask.
  
      Returns:
          Tensor: Generated mask.
      """
      min_perlin_scale = 0
      perlin_scale = 6
      perlin_scalex = 2 ** (
          torch.randint(min_perlin_scale, perlin_scale, (1,)).numpy()[0]
      )
      perlin_scaley = 2 ** (
          torch.randint(min_perlin_scale, perlin_scale, (1,)).numpy()[0]
      )
      threshold = 0.5
      perlin_noise_np = _rand_perlin_2d_np(
          (height, width), (perlin_scalex, perlin_scaley)
      )
      perlin_noise_np = self.rot(image=perlin_noise_np)
      mask = np.where(
          perlin_noise_np > threshold,
          np.ones_like(perlin_noise_np),
          np.zeros_like(perlin_noise_np),
      )
      mask = np.expand_dims(mask, axis=2).astype(np.float32)
      mask = torch.from_numpy(mask)
  
      return mask
  
file_path: anomalib/src/anomalib/models/dsr/anomaly_generator.py
imports: from typing import List
  import imgaug.augmenters
  import numpy
  import torch
  from torch import Tensor, nn
  from anomalib.data.utils.generators.perlin import _rand_perlin_2d_np
label_desc: Use image node_id 2 for calling the DsrAnomalyGenerator obj's underlying member method code with example usage: obj.generate_anomaly(height, width) and returns: mask