class_docstr: Inter-attention module with k,v from source and q from target
  
  Parameters
  ----------
  d_query : int
      query/decoder dimension
  d_kv: int
      key-value/encoder dimension
  n_head : int, optional
      number of attention heads, by default 1
  bias : bool, optional
      add bias term in input and output projections, by default True
  apply_kv_proj : bool, optional
      if True, apply linear projection to kv tensor and d_hidden = d_query,
          attention is performed in query feature space;
      if False, no linear porjection is applied and d_hidden = d_kv,
          attention is performed in key-value feature space;
          note that if n_head=1 in this case, it reduces to Luong's dot attention;
      by default True
  apply_rel_dist : Optional[str], optional
      add relative distance embeddings to dot-product attention, can be
          'add' (linearly combine key and dist),
          'dot' (dot product between key and dist),
          or None (disabled),
      by default None
  share_values : bool, optional
      if True, a value reprensentation is shared by all attention heads;
      only works when apply_kv_proj is False;
      by default False
      ref. https://arxiv.org/abs/1912.09363
  dropout : float, optional
      dropout rate, by default 0.0
  temperature : float, optional
      softmax temperature, by default 1.0
class_docstr_tok: ["Inter-attention","module","with","k",",","v","from","source","and","q","from","target","Parameters","--","--","--","--","--","d_query",":","int","query\/decoder","dimension","d_kv",":","int","key-value\/encoder","dimension","n_head",":","int",",","optional","number","of","attention","heads",",","by","default","1","bias",":","bool",",","optional","add","bias","term","in","input","and","output","projections",",","by","default","True","apply_kv_proj",":","bool",",","optional","if","True",",","apply","linear","projection","to","kv","tensor","and","d_hidden","=","d_query",",","attention","is","performed","in","query","feature","space",";","if","False",",","no","linear","porjection","is","applied","and","d_hidden","=","d_kv",",","attention","is","performed","in","key-value","feature","space",";","note","that","if","n_head=1","in","this","case",",","it","reduces","to","Luong","'s","dot","attention",";","by","default","True","apply_rel_dist",":","Optional","[","str","]",",","optional","add","relative","distance","embeddings","to","dot-product","attention",",","can","be","'add","'","(","linearly","combine","key","and","dist",")",",","'dot","'","(","dot","product","between","key","and","dist",")",",","or","None","(","disabled",")",",","by","default","None","share_values",":","bool",",","optional","if","True",",","a","value","reprensentation","is","shared","by","all","attention","heads",";","only","works","when","apply_kv_proj","is","False",";","by","default","False","ref",".","https",":","\/\/arxiv.org\/abs\/1912.09363","dropout",":","float",",","optional","dropout","rate",",","by","default","0.0","temperature",":","float",",","optional","softmax","temperature",",","by","default","1.0"]
code: def _compute_qkv(
      self, query: Tensor, src: Tensor
  ) -> Tuple[Tensor, Tensor, Tensor]:
      # [batch, qlen, d_hidden]
      q = linear(query, self._query_proj_weight, self._query_proj_bias)
      q = self._split_head(q)
      if self.apply_kv_proj:
          # [batch, klen, 2 * d_hidden]
          kv = linear(src, self._kv_proj_weight, self._kv_proj_bias)
          k, v = kv.chunk(2, dim=-1)
          k = self._split_head(k)
          v = self._split_head(v)
      else:
          k = v = self._split_head(src.clone())
      return q, k, v
  
file_path: gluonts/src/gluonts/nursery/daf/tslib/nn/attention/interattn.py
imports: from typing import Tuple, Optional
  import math
  import torch
  from torch import Tensor, BoolTensor
  from torch import nn
  from torch.nn import init
  from torch.nn.functional import linear
  from .base import Attention
  from .posemb import SinusoidalPositionalEmbedding
label_desc: Use image node_id 3 for calling the InterAttention obj's underlying member method code with example usage: obj._compute_qkv(query, src) and returns: q,  k,  v