class_docstr: A module that implements a gated linear transformation for the combination of entities and literals.
  
  Compared to the other Combinations, this combination makes use of a gating mechanism commonly found in RNNs.
  The main goal of this gating mechanism is to learn which parts of the additional literal information is
  useful or not and act accordingly, by incorporating them into the new combined embedding or discarding them.
  
  For given entity representation $\mathbf{x}_e \in \mathbb{R}^{d_e}$ and literal representation
  $\mathbf{x}_l \in \mathbb{R}^{d_l}$, the module calculates
  
  .. math ::
  
      z = f_{gate}(\mathbf{W}_e x_e + \mathbf{W}_l x_l + \mathbf{b})
      h = f_{hidden}(\mathbf{W} [x_e; x_l])
      y = Dropout(z \odot h + (1 - z) \odot x)
  
  where $\mathbf{W}_e \in \mathbb{R}^{d_e \times d_e}$,$\mathbf{W}_l \in \mathbb{R}^{d_l \times d_e}$,
  $\mathbf{W} \in \mathbb{R}^{(d_e + d_l) \ times d_e}$, and $\mathbf{b} \in \mathbb{R}^{d_e}$ are trainable
  parameters, $f_{gate}$ and $f_{hidden}$ are activation functions, defaulting to sigmoid and tanh, $\odot$ denotes
  the element-wise multiplication, and $[x_e; x_l]$ the concatenation operation.
  
  .. note ::
  
      We can alternatively express the gate
  
      .. math ::
  
          z = f_{gate}(\mathbf{W}_e x_e + \mathbf{W}_l x_l + \mathbf{b})
  
      as
  
      .. math ::
  
          z = f_{gate}(\mathbf{W}_{el} [x_e; x_l] + \mathbf{b})
  
      with $\mathbf{W}_{el} \in \mathbb{R}^{(d_e + d_l) \times d_e}$.
  
  Implementation based on https://github.com/SmartDataAnalytics/LiteralE/blob/master/model.py Gate class.
docstr: Instantiate the module.
  
  :param entity_dim:
      the dimension of the entity representations.
  :param literal_dim:
      the dimension of the literals; defaults to entity_dim
  :param input_dropout:
      the dropout to use
  :param gate_activation:
      the activation to use on the gate, or a hint thereof
  :param gate_activation_kwargs:
      the keyword arguments to be used to instantiate the `gate_activation` if
      a class or name is given instead of a pre-instantiated activation module
  :param hidden_activation:
      the activation to use in the hidden layer, or a hint thereof
  :param hidden_activation_kwargs:
      the keyword arguments to be used to instantiate the hidden activation if
      a class or name is given instead of a pre-instantiated activation module
docstr_tok: ["Instantiate","the","module",".",":","param","entity_dim",":","the","dimension","of","the","entity","representations",".",":","param","literal_dim",":","the","dimension","of","the","literals",";","defaults","to","entity_dim",":","param","input_dropout",":","the","dropout","to","use",":","param","gate_activation",":","the","activation","to","use","on","the","gate",",","or","a","hint","thereof",":","param","gate_activation_kwargs",":","the","keyword","arguments","to","be","used","to","instantiate","the","`","gate_activation","`","if","a","class","or","name","is","given","instead","of","a","pre-instantiated","activation","module",":","param","hidden_activation",":","the","activation","to","use","in","the","hidden","layer",",","or","a","hint","thereof",":","param","hidden_activation_kwargs",":","the","keyword","arguments","to","be","used","to","instantiate","the","hidden","activation","if","a","class","or","name","is","given","instead","of","a","pre-instantiated","activation","module"]
code: def __init__(
      self,
      entity_dim: int = 32,
      literal_dim: Optional[int] = None,
      input_dropout: float = 0.0,
      gate_activation: HintOrType[nn.Module] = nn.Sigmoid,
      gate_activation_kwargs: Optional[Mapping[str, Any]] = None,
      hidden_activation: HintOrType[nn.Module] = nn.Tanh,
      hidden_activation_kwargs: Optional[Mapping[str, Any]] = None,
  ) -> None:
      """Instantiate the module.
  
      :param entity_dim:
          the dimension of the entity representations.
      :param literal_dim:
          the dimension of the literals; defaults to entity_dim
      :param input_dropout:
          the dropout to use
      :param gate_activation:
          the activation to use on the gate, or a hint thereof
      :param gate_activation_kwargs:
          the keyword arguments to be used to instantiate the `gate_activation` if
          a class or name is given instead of a pre-instantiated activation module
      :param hidden_activation:
          the activation to use in the hidden layer, or a hint thereof
      :param hidden_activation_kwargs:
          the keyword arguments to be used to instantiate the hidden activation if
          a class or name is given instead of a pre-instantiated activation module
      """
      super().__init__()
      literal_dim = literal_dim or entity_dim
      self.dropout = nn.Dropout(input_dropout)
      # the gate
      self.gate = ConcatProjectionCombination(
          input_dims=[entity_dim, literal_dim],
          output_dim=entity_dim,
          bias=True,
          activation=gate_activation,
          activation_kwargs=gate_activation_kwargs,
      )
      # the combination
      self.combination = ConcatProjectionCombination(
          input_dims=[entity_dim, literal_dim],
          output_dim=entity_dim,
          bias=True,
          activation=hidden_activation,
          activation_kwargs=hidden_activation_kwargs,
      )
  
imports: import logging
  from abc import ABC, abstractmethod
  from typing import Any, Callable, Iterable, Mapping, Optional, Sequence, Tuple
  import torch
  from class_resolver import ClassResolver, Hint, HintOrType, OptionalKwargs
  from class_resolver.contrib.torch import activation_resolver, aggregation_resolver
  from torch import nn
  from ..utils import ExtraReprMixin, combine_complex, split_complex
label_desc: Use image node_id 1 to create a new GatedCombination object from inherited base classes: Combination with example: obj = GatedCombination(entity_dim, literal_dim, input_dropout, gate_activation, gate_activation_kwargs, hidden_activation, hidden_activation_kwargs)