class_docstr: A UNetModel that conditions on text with an encoding transformer.
  
  Expects an extra kwarg `tokens` of text.
  
  :param text_ctx: number of text tokens to expect.
  :param xf_width: width of the transformer.
  :param xf_layers: depth of the transformer.
  :param xf_heads: heads in the transformer.
  :param xf_final_ln: use a LayerNorm after the output layer.
  :param tokenizer: the text tokenizer for sampling/vocab size.
code: def __init__(
      self,
      text_ctx,
      xf_width,
      xf_layers,
      xf_heads,
      xf_final_ln,
      tokenizer,
      *args,
      cache_text_emb=False,
      xf_ar=0.0,
      xf_padding=False,
      share_unemb=False,
      **kwargs,
  ):
      self.text_ctx = text_ctx
      self.xf_width = xf_width
      self.xf_ar = xf_ar
      self.xf_padding = xf_padding
      self.tokenizer = tokenizer
  
      if not xf_width:
          super().__init__(*args, **kwargs, encoder_channels=None)
      else:
          super().__init__(*args, **kwargs, encoder_channels=xf_width)
      if self.xf_width:
          self.transformer = Transformer(
              text_ctx,
              xf_width,
              xf_layers,
              xf_heads,
          )
          if xf_final_ln:
              self.final_ln = LayerNorm(xf_width)
          else:
              self.final_ln = None
  
          self.token_embedding = nn.Embedding(
              self.tokenizer.n_vocab, xf_width
          )
          self.positional_embedding = nn.Parameter(
              th.empty(text_ctx, xf_width, dtype=th.float32)
          )
          self.transformer_proj = nn.Linear(
              xf_width, self.model_channels * 4
          )
  
          if self.xf_padding:
              self.padding_embedding = nn.Parameter(
                  th.empty(text_ctx, xf_width, dtype=th.float32)
              )
          if self.xf_ar:
              self.unemb = nn.Linear(xf_width, self.tokenizer.n_vocab)
              if share_unemb:
                  self.unemb.weight = self.token_embedding.weight
  
      self.cache_text_emb = cache_text_emb
      self.cache = None
  
imports: import torch
  import torch.nn
  import torch.nn.functional
  from .nn import timestep_embedding
  from .unet import UNetModel
  from .xf import LayerNorm, Transformer, convert_module_to_f16
label_desc: Use image node_id 1 to create a new Text2ImUNet object from inherited base classes: UNetModel with example: obj = Text2ImUNet(text_ctx, xf_width, xf_layers, xf_heads, xf_final_ln, tokenizer)