class_docstr: Context Encoding for Semantic Segmentation.
  
  This head is the implementation of `EncNet
  <https://arxiv.org/abs/1803.08904>`_.
  
  Args:
      num_codes (int): Number of code words. Default: 32.
      use_se_loss (bool): Whether use Semantic Encoding Loss (SE-loss) to
          regularize the training. Default: True.
      add_lateral (bool): Whether use lateral connection to fuse features.
          Default: False.
      loss_se_decode (dict): Config of decode loss.
          Default: dict(type='CrossEntropyLoss', use_sigmoid=True).
class_docstr_tok: ["Context","Encoding","for","Semantic","Segmentation",".","This","head","is","the","implementation","of","`","EncNet","<","https",":","\/\/arxiv.org\/abs\/1803.08904",">","`","_",".","Args",":","num_codes","(","int",")",":","Number","of","code","words",".","Default",":","32.","use_se_loss","(","bool",")",":","Whether","use","Semantic","Encoding","Loss","(","SE-loss",")","to","regularize","the","training",".","Default",":","True",".","add_lateral","(","bool",")",":","Whether","use","lateral","connection","to","fuse","features",".","Default",":","False",".","loss_se_decode","(","dict",")",":","Config","of","decode","loss",".","Default",":","dict","(","type='CrossEntropyLoss","'",",","use_sigmoid=True",")","."]
docstr: Forward function.
docstr_tok: ["Forward","function","."]
code: def forward(self, inputs):
      """Forward function."""
      inputs = self._transform_inputs(inputs)
      feat = self.bottleneck(inputs[-1])
      if self.add_lateral:
          laterals = [
              resize(
                  lateral_conv(inputs[i]),
                  size=feat.shape[2:],
                  mode="bilinear",
                  align_corners=self.align_corners,
              )
              for i, lateral_conv in enumerate(self.lateral_convs)
          ]
          feat = self.fusion(torch.cat([feat, *laterals], 1))
      encode_feat, output = self.enc_module(feat)
      output = self.cls_seg(output)
      if self.use_se_loss:
          se_output = self.se_layer(encode_feat)
          return output, se_output
      else:
          return output
  
file_path: lavis/lavis/common/annotator/uniformer/mmseg/models/decode_heads/enc_head.py
imports: import torch
  import torch.nn
  import torch.nn.functional
  from annotator.uniformer.mmcv.cnn import ConvModule, build_norm_layer
  from annotator.uniformer.mmseg.ops import Encoding, resize
  from ..builder import HEADS, build_loss
  from .decode_head import BaseDecodeHead
label_desc: Use image node_id 2 for calling the EncHead obj's underlying member method code with example usage: obj.forward(inputs) and returns: output,  se_output, output