class_docstr: AutoCorrelation Mechanism with the following two phases:
  (1) period-based dependencies discovery
  (2) time delay aggregation
  This block can replace the self-attention family mechanism seamlessly.
class_docstr_tok: ["AutoCorrelation","Mechanism","with","the","following","two","phases",":","(","1",")","period-based","dependencies","discovery","(","2",")","time","delay","aggregation","This","block","can","replace","the","self-attention","family","mechanism","seamlessly","."]
docstr: Standard version of Autocorrelation
docstr_tok: ["Standard","version","of","Autocorrelation"]
code: def time_delay_agg_full(self, values, corr):
      """
      Standard version of Autocorrelation
      """
      batch = values.shape[0]
      head = values.shape[1]
      channel = values.shape[2]
      length = values.shape[3]
      # index init
      init_index = (
          torch.arange(length)
          .unsqueeze(0)
          .unsqueeze(0)
          .unsqueeze(0)
          .repeat(batch, head, channel, 1)
      )
      if torch.cuda.is_available():
          init_index = init_index.cuda()
      # find top k
      top_k = int(self.factor * math.log(length))
      weights = torch.topk(corr, top_k, dim=-1)[0]
      delay = torch.topk(corr, top_k, dim=-1)[1]
      # update corr
      tmp_corr = torch.softmax(weights, dim=-1)
      # aggregation
      tmp_values = values.repeat(1, 1, 1, 2)
      delays_agg = torch.zeros_like(values).float()
      for i in range(top_k):
          tmp_delay = init_index + delay[..., i].unsqueeze(-1)
          pattern = torch.gather(tmp_values, dim=-1, index=tmp_delay)
          delays_agg = delays_agg + pattern * (
              tmp_corr[..., i].unsqueeze(-1)
          )
      return delays_agg
  
file_path: BigDL/python/chronos/src/bigdl/chronos/model/autoformer/layers/AutoCorrelation.py
imports: import torch
  import torch.nn
  import torch.nn.functional
  import numpy
  import math
  from math import sqrt
  import os
label_desc: Use image node_id 4 for calling the AutoCorrelation obj's underlying member method code with example usage: obj.time_delay_agg_full(values, corr) and returns: delays_agg