class_docstr: Channel attention module
  from the paper `"Dual Attention Network for Scene Segmentation"
  <https://arxiv.org/abs/1809.02983>`
  CAM_Module explicitly models interdependencies between channels.
class_docstr_tok: ["Channel","attention","module","from","the","paper","`","``","Dual","Attention","Network","for","Scene","Segmentation","''","<","https",":","\/\/arxiv.org\/abs\/1809.02983",">","`","CAM_Module","explicitly","models","interdependencies","between","channels","."]
docstr: inputs :
      x : input feature maps( B X C X H X W)
  returns :
      out : attention value + input feature
      attention: B X C X C
docstr_tok: ["inputs",":","x",":","input","feature","maps","(","B","X","C","X","H","X","W",")","returns",":","out",":","attention","value","+","input","feature","attention",":","B","X","C","X","C"]
code: def hybrid_forward(self, F, x, **kwargs):
      """
      inputs :
          x : input feature maps( B X C X H X W)
      returns :
          out : attention value + input feature
          attention: B X C X C
      """
      gamma = kwargs["gamma"]
      proj_query = F.reshape(x, (0, 0, -1))
      proj_key = F.reshape(x, (0, 0, -1))
      energy = F.batch_dot(proj_query, proj_key, transpose_b=True)
      energy_new = (
          F.max(energy, -1, True).broadcast_like(energy) - energy
      )
      attention = F.softmax(energy_new)
      proj_value = F.reshape(x, (0, 0, -1))
  
      out = F.batch_dot(attention, proj_value)
      out = F.reshape_like(
          out, x, lhs_begin=2, lhs_end=None, rhs_begin=2, rhs_end=None
      )
  
      out = F.broadcast_mul(gamma, out) + x
      return out
  
file_path: gluon-cv/gluoncv/model_zoo/attention.py
imports: import mxnet
  from mxnet.gluon import nn
  from mxnet.gluon.nn import HybridBlock
label_desc: Use image node_id 2 for calling the CAM_Module obj's underlying member method code with example usage: obj.hybrid_forward(F, x) and returns: out