class_docstr: Cascade Encoder Decoder segmentors.
  
  CascadeEncoderDecoder almost the same as EncoderDecoder, while decoders of
  CascadeEncoderDecoder are cascaded. The output of previous decoder_head
  will be the input of next decoder_head.
class_docstr_tok: ["Cascade","Encoder","Decoder","segmentors",".","CascadeEncoderDecoder","almost","the","same","as","EncoderDecoder",",","while","decoders","of","CascadeEncoderDecoder","are","cascaded",".","The","output","of","previous","decoder_head","will","be","the","input","of","next","decoder_head","."]
docstr: Run forward function and calculate loss for decode head in
  training.
docstr_tok: ["Run","forward","function","and","calculate","loss","for","decode","head","in","training","."]
code: def _decode_head_forward_train(self, x, img_metas, gt_semantic_seg):
      """Run forward function and calculate loss for decode head in
      training."""
      losses = dict()
  
      loss_decode = self.decode_head[0].forward_train(
          x, img_metas, gt_semantic_seg, self.train_cfg
      )
  
      losses.update(add_prefix(loss_decode, "decode_0"))
  
      for i in range(1, self.num_stages):
          # forward test again, maybe unnecessary for most methods.
          prev_outputs = self.decode_head[i - 1].forward_test(
              x, img_metas, self.test_cfg
          )
          loss_decode = self.decode_head[i].forward_train(
              x,
              prev_outputs,
              img_metas,
              gt_semantic_seg,
              self.train_cfg,
          )
          losses.update(add_prefix(loss_decode, f"decode_{i}"))
  
      return losses
  
file_path: lavis/lavis/common/annotator/uniformer/mmseg/models/segmentors/cascade_encoder_decoder.py
imports: from torch import nn
  from annotator.uniformer.mmseg.core import add_prefix
  from annotator.uniformer.mmseg.ops import resize
  from ..None import builder
  from ..builder import SEGMENTORS
  from .encoder_decoder import EncoderDecoder
label_desc: Use image node_id 5 for calling the CascadeEncoderDecoder obj's underlying member method code with example usage: obj._decode_head_forward_train(x, img_metas, gt_semantic_seg) and returns: losses