parameters: (self, x)
return_statement: return out
docstring: inputs :
                  x : input feature maps( B X C X H X W)
              returns :
                  out : attention value + input feature
                  attention: B X (HxW) X (HxW)
docstring_summary: inputs :
                  x : input feature maps( B X C X H X W)
              returns :
                  out : attention value + input feature
                  attention: B X (HxW) X (HxW)
docstring_tokens: inputs : x : input feature maps ( B X C X H X W ) returns : out : attention value + input feature attention : B X ( HxW ) X ( HxW )
function: def forward(self, x):
          """
              inputs :
                  x : input feature maps( B X C X H X W)
              returns :
                  out : attention value + input feature
                  attention: B X (HxW) X (HxW)
          """
          m_batchsize, C, height, width = x.size()
          proj_query = self.query_conv(x).view(m_batchsize, -1, width*height).permute(0, 2, 1)
          proj_key = self.key_conv(x).view(m_batchsize, -1, width*height)
          energy = torch.bmm(proj_query, proj_key)
          attention = self.softmax(energy)
          proj_value = self.value_conv(x).view(m_batchsize, -1, width*height)
  
          out = torch.bmm(proj_value, attention.permute(0, 2, 1))
          out = out.view(m_batchsize, C, height, width)
  
          out = self.gamma*out + x
          return out
function_tokens: def forward ( self , x ) : m_batchsize , C , height , width = x . size ( ) proj_query = self . query_conv ( x ) . view ( m_batchsize , - 1 , width * height ) . permute ( 0 , 2 , 1 ) proj_key = self . key_conv ( x ) . view ( m_batchsize , - 1 , width * height ) energy = torch . bmm ( proj_query , proj_key ) attention = self . softmax ( energy ) proj_value = self . value_conv ( x ) . view ( m_batchsize , - 1 , width * height ) out = torch . bmm ( proj_value , attention . permute ( 0 , 2 , 1 ) ) out = out . view ( m_batchsize , C , height , width ) out = self . gamma * out + x return out