code: def one_hot_minus(inputs, shift):
      """Performs (inputs - shift) % vocab_size in the one-hot space.
      Args:
          inputs: Tensor of shape `[..., vocab_size]`. Typically a soft/hard one-hot
          Tensor.
          shift: Tensor of shape `[..., vocab_size]`. Typically a soft/hard one-hot
          Tensor specifying how much to shift the corresponding one-hot vector in
          inputs. Soft values perform a "weighted shift": for example,
          shift=[0.2, 0.3, 0.5] performs a linear combination of 0.2 * shifting by
          zero; 0.3 * shifting by one; and 0.5 * shifting by two.
      Returns:
          Tensor of same shape and dtype as inputs.
      """
      # TODO: Implement with circular conv1d.
      # inputs = torch.tensor(inputs)
      shift = shift.type(inputs.dtype)
      vocab_size = inputs.shape[-1]
      # Form a [..., vocab_size, vocab_size] matrix. Each batch element of
      # inputs will vector-matrix multiply the vocab_size x vocab_size matrix. This
      # "shifts" the inputs batch element by the corresponding shift batch element.
      shift_matrix = torch.stack(
          [torch.roll(shift, i, dims=-1) for i in range(vocab_size)],
          dim=-2,
      )
      outputs = torch.einsum("...v,...uv->...u", inputs, shift_matrix)
      return outputs
  
file_path: DIG/dig/ggraph/method/GraphDF/model/df_utils.py
imports: import sys
  import warnings
  import torch
  import torch.nn.functional
  import numpy
label_desc: Use image node_id 5 for calling a global function with example usage: one_hot_minus(inputs, shift) and returns: outputs