code: def forward(
      self,
      value: Tensor,
      shape: Optional[pt.Tensor] = None,
      estimate: Optional[pt.Tensor] = None,
      mask: Optional[BoolTensor] = None,
  ) -> Tensor:
      if self.shape_qk and shape is None:
          raise ValueError("A separated shape input is required.")
      if self.composite_attention and estimate is None:
          raise ValueError("A separated estimate input is required")
      if self.pre_ln:
          x = self.layer_norm(value)
      else:
          x = value
      if not self.shape_qk:
          x = self.attention(x, mask=mask)
      else:
          if shape is None:
              raise ValueError(
                  "if shape attention is enabled, "
                  "a shape tensor must be provided."
              )
          if not self.composite_attention:
              x = self.attention(x, shape, mask=mask)
          else:
              if estimate is None:
                  raise ValueError(
                      "if composite attention is enabled, "
                      "an estimate tensor must be provided."
                  )
              x = self.attention(x, shape, estimate, mask=mask)
      x = self.dropout(x)
      value = value + x
      if not self.pre_ln:
          value = self.layer_norm(value)
      value = self.ffn(value)
      return value
  
file_path: gluonts/src/gluonts/nursery/daf/tslib/nn/transformer.py
imports: from typing import Optional, List
  from collections import OrderedDict
  import warnings
  import torch
  from torch import Tensor, BoolTensor
  from torch import nn
  from .attention import SelfAttention, GroupSelfAttention, CompositeAttention, InterAttention
  from .activations import Swish
label_desc: Use image node_id 2 for calling the TransformerEncoderBlock obj's underlying member method code with example usage: obj.forward(value, shape, estimate, mask) and returns: value