class_docstr: The half UNet model with attention and timestep embedding.
  For usage, see UNet.
class_docstr_tok: ["The","half","UNet","model","with","attention","and","timestep","embedding",".","For","usage",",","see","UNet","."]
docstr: Apply the model to an input batch.
  :param x: an [N x C x ...] Tensor of inputs.
  :param timesteps: a 1-D batch of timesteps.
  :return: an [N x K] Tensor of outputs.
docstr_tok: ["Apply","the","model","to","an","input","batch",".",":","param","x",":","an","[","N","x","C","x","...","]","Tensor","of","inputs",".",":","param","timesteps",":","a","1-D","batch","of","timesteps",".",":","return",":","an","[","N","x","K","]","Tensor","of","outputs","."]
code: def forward(self, x, timesteps):
      """
      Apply the model to an input batch.
      :param x: an [N x C x ...] Tensor of inputs.
      :param timesteps: a 1-D batch of timesteps.
      :return: an [N x K] Tensor of outputs.
      """
      emb = self.time_embed(
          timestep_embedding(timesteps, self.model_channels)
      )
  
      results = []
      h = x.type(self.dtype)
      for module in self.input_blocks:
          h = module(h, emb)
          if self.pool.startswith("spatial"):
              results.append(h.type(x.dtype).mean(dim=(2, 3)))
      h = self.middle_block(h, emb)
      if self.pool.startswith("spatial"):
          results.append(h.type(x.dtype).mean(dim=(2, 3)))
          h = th.cat(results, axis=-1)
          return self.out(h)
      else:
          h = h.type(x.dtype)
          return self.out(h)
  
imports: from abc import abstractmethod
  from functools import partial
  import math
  from typing import Iterable
  import numpy
  import torch
  import torch.nn
  import torch.nn.functional
  from ldm.modules.diffusionmodules.util import checkpoint, conv_nd, linear, avg_pool_nd, zero_module, normalization, timestep_embedding
  from ldm.modules.attention import SpatialTransformer
label_desc: Use image node_id 4 for calling the EncoderUNetModel obj's underlying member method code with example usage: obj.forward(x, timesteps) and returns: self, self