class_docstr: Class defining a region where a text guided diffusion process is acting
class_docstr_tok: ["Class","defining","a","region","where","a","text","guided","diffusion","process","is","acting"]
code: def __post_init__(self):
      super().__post_init__()
      # Mask weight cannot be negative
      if self.mask_weight < 0:
          raise ValueError(
              f"A Text2ImageRegion must be defined with non-negative mask weight, found {self.mask_weight}"
          )
      # Mask type must be an actual known mask
      if self.mask_type not in [e.value for e in MaskModes]:
          raise ValueError(
              f"A Text2ImageRegion was defined with mask {self.mask_type}, which is not an accepted mask ({[e.value for e in MaskModes]})"
          )
      # Randomize arguments if given as None
      if self.guidance_scale is None:
          self.guidance_scale = np.random.randint(5, 30)
      # Clean prompt
      self.prompt = re.sub(" +", " ", self.prompt).replace("\n", " ")
  
imports: import re
  from copy import deepcopy
  from dataclasses import asdict, dataclass
  from enum import Enum
  from typing import List, Optional, Union
  import numpy
  import torch
  from numpy import exp, pi, sqrt
  from torchvision.transforms.functional import resize
  from tqdm.auto import tqdm
  from transformers import CLIPFeatureExtractor, CLIPTextModel, CLIPTokenizer
  from diffusers.models import AutoencoderKL, UNet2DConditionModel
  from diffusers.pipeline_utils import DiffusionPipeline
  from diffusers.pipelines.stable_diffusion import StableDiffusionSafetyChecker
  from diffusers.schedulers import DDIMScheduler, LMSDiscreteScheduler, PNDMScheduler
label_desc: Use image node_id 1 for calling the Text2ImageRegion obj's underlying member method code with example usage: obj.__post_init__() without return types