code: def _transform_forward(
      x: torch.Tensor, dim: int, duration: int
  ) -> torch.Tensor:
      assert not x.requires_grad
      assert dim < 0
      assert duration == x.size(dim)
      time_domain = x
      new_size = next_fast_len(duration)
      if new_size == duration:
          freq_domain = x
      else:
          freq_domain = pad(
              x, (0, 0) * (-1 - dim) + (0, new_size - duration)
          )
      freq_domain = dct(freq_domain, dim)
      return torch.cat([time_domain, freq_domain], dim=dim)
  
file_path: pyro/pyro/optim/dct_adam.py
imports: import math
  from typing import Callable, Dict, Optional, Tuple
  import torch
  from torch.nn.functional import pad
  from torch.optim.optimizer import Optimizer
  from pyro.ops.tensor_utils import dct, idct, next_fast_len
label_desc: Use image node_id 1 for calling a global function with example usage: _transform_forward(x, dim, duration) and returns: torch