code: def cumulativeMeanNormalizedDifferenceFunction(df, N, eps=1e-8):
      """
      Compute cumulative mean normalized difference function (CMND).
  
      This corresponds to equation (8) in [1]
  
      :param df: Difference function
      :param N: length of data
      :return: cumulative mean normalized difference function
      :rtype: list
      """
      # np.seterr(divide='ignore', invalid='ignore')
      # scipy method, assert df>0 for all element
      #   cmndf = df[1:] * np.asarray(list(range(1, N)))
      # / (np.cumsum(df[1:]).astype(float) + eps)
      B, _ = df.shape
      cmndf = (
          df[:, 1:]
          * torch.arange(1, N, device=df.device, dtype=df.dtype).view(
              1, -1
          )
          / (df[:, 1:].cumsum(dim=-1) + eps)
      )
      return torch.cat(
          [torch.ones([B, 1], device=df.device, dtype=df.dtype), cmndf],
          dim=-1,
      )
  
imports: import numpy
  import torch
  import torch.nn.functional
label_desc: Use image node_id 3 for calling a global function with example usage: cumulativeMeanNormalizedDifferenceFunction(df, N, eps) and returns: torch