code: def _calculate_dft_matrix(
      n_fft: Var,
      onesided: bool = False,
      before_op: Operation = None,
  ) -> Tuple[Var, Var]:
      """
      The core issue is how to derive the DFT matrix. As the DFT matrix is consist of different powers
      of `w`, where w=e^(2pi/N i), we need to separate the real and imaginary part of w. To achieve
      that, we need to find a way to construct the following matrix (from the power of `w` in DFT):
          0    0    0      ...    0
          0    1    2      ...    N-1
          0    2    4      ...    2(N-1)
          ...    ....      ...
          0   N-1  2(N-1)  ...    (N-1)(N-1)
      This matrix could be derived by outer product of two range tensors.
  
      After getting that base matrix, we can take sin and cos to get the corresponding `sin_base` and
      `cos_base` matrix.
  
      If the onesided flag is passed, we can take advantage of Hermitian symmetry and return a
      weight matrix consisting of only the first (n_fft // 2 + 1) values.
      """
      n_fft = mb.cast(x=n_fft, dtype="fp32", before_op=before_op)
      half = mb.floor_div(x=n_fft, y=2.0, before_op=before_op)
      half = mb.add(x=half, y=1.0, before_op=before_op)
  
      tmp_x = mb.range_1d(
          start=0.0,
          end=(half if onesided else n_fft),
          step=1.0,
          before_op=before_op,
      )
      tmp_y = mb.range_1d(
          start=0.0, end=n_fft, step=1.0, before_op=before_op
      )
  
      # Use MIL ops to calculate base = torch.outer(tmp, tmp) * (2 * torch.pi / N).
      tmp_x = mb.reshape(x=tmp_x, shape=[-1, 1], before_op=before_op)
      tmp_y = mb.reshape(x=tmp_y, shape=[1, -1], before_op=before_op)
  
      base = mb.matmul(x=tmp_x, y=tmp_y, before_op=before_op)
      base = mb.mul(x=base, y=2 * np.pi, before_op=before_op)
      base = mb.real_div(x=base, y=n_fft, before_op=before_op)
  
      # Get real part and imaginary part separately.
      cos_base = mb.cos(x=base, before_op=before_op)
      sin_base = mb.sin(x=base, before_op=before_op)
  
      return cos_base, sin_base
  
imports: import functools
  from typing import Callable, Dict, Optional, Tuple
  import numpy
  from coremltools.converters.mil.mil import Builder
  from coremltools.converters.mil.mil import types
  from coremltools.converters.mil.mil.operation import Operation
  from coremltools.converters.mil.mil.ops.defs.complex_dialect_ops import fft_canonicalize_length_dim, fft_canonicalize_shapes_dims
  from coremltools.converters.mil.mil.passes.graph_pass import AbstractGraphPass
  from coremltools.converters.mil.mil.passes.helper import block_context_manager
  from coremltools.converters.mil.mil.passes.pass_registry import register_pass
  from coremltools.converters.mil.mil.var import ComplexVar, Var
label_desc: Use image node_id 3 for calling a global function with example usage: _calculate_dft_matrix(n_fft, onesided, before_op) and returns: cos_base,  sin_base