class_docstr: Duration calculator module.
code: def _calculate_focus_rete(att_ws):
      if len(att_ws.shape) == 2:
          # tacotron 2 case -> (T_feats, T_text)
          return att_ws.max(dim=-1)[0].mean()
      elif len(att_ws.shape) == 4:
          # transformer case -> (#layers, #heads, T_feats, T_text)
          return att_ws.max(dim=-1)[0].mean(dim=-1).max()
      else:
          raise ValueError(
              "att_ws should be 2 or 4 dimensional tensor."
          )
  
imports: from typing import Tuple
  import torch
label_desc: Use image node_id 2 for calling the DurationCalculator obj's underlying member method code with example usage: obj._calculate_focus_rete(att_ws) and returns: att_ws, att_ws