class_docstr: An attention block that allows spatial positions to attend to each other.
  
  Originally ported from here, but adapted to the N-d case.
  https://github.com/hojonathanho/diffusion/blob/1e0dceb3b3495bbe19116a5e1b3596cd0706c543/diffusion_tf/models/unet.py#L66.
class_docstr_tok: ["An","attention","block","that","allows","spatial","positions","to","attend","to","each","other",".","Originally","ported","from","here",",","but","adapted","to","the","N-d","case",".","https",":","\/\/github.com\/hojonathanho\/diffusion\/blob\/1e0dceb3b3495bbe19116a5e1b3596cd0706c543\/diffusion_tf\/models\/unet.py","#","L66","."]
code: def forward(self, x, encoder_out=None):
      if encoder_out is None:
          return checkpoint(
              self._forward,
              (x,),
              self.parameters(),
              self.use_checkpoint,
          )
      else:
          return checkpoint(
              self._forward,
              (x, encoder_out),
              self.parameters(),
              self.use_checkpoint,
          )
  
imports: from abc import abstractmethod
  import math
  import numpy
  import torch
  import torch.nn
  import torch.nn.functional
  from .fp16_util import convert_module_to_f16, convert_module_to_f32
  from .nn import checkpoint, conv_nd, linear, avg_pool_nd, zero_module, normalization, timestep_embedding
label_desc: Use image node_id 2 for calling the AttentionBlock obj's underlying member method code with example usage: obj.forward(x, encoder_out) and returns: checkpoint, checkpoint