code: def context_gate_factory(
      gate_type,
      embeddings_size,
      decoder_size,
      attention_size,
      output_size,
  ):
      """Returns the correct ContextGate class"""
  
      gate_types = {
          "source": SourceContextGate,
          "target": TargetContextGate,
          "both": BothContextGate,
      }
  
      assert (
          gate_type in gate_types
      ), "Not valid ContextGate type: {0}".format(gate_type)
      return gate_types[gate_type](
          embeddings_size, decoder_size, attention_size, output_size
      )
  
file_path: OpenNMT-py/onmt/modules/gate.py
imports: import torch
  import torch.nn
label_desc: Use image node_id 1 for calling a global function with example usage: context_gate_factory(gate_type, embeddings_size, decoder_size, attention_size, output_size) and returns: gate_types