class_docstr: Args:
class_docstr_tok: ["Args",":"]
code: def shift(x, n_segment, fold_div=3, inplace=False):
      nt, c, h, w = x.size()
      n_batch = nt // n_segment
      x = x.view(n_batch, n_segment, c, h, w)
  
      fold = c // fold_div
      if inplace:
          # Due to some out of order error when performing parallel computing.
          # May need to write a CUDA kernel.
          raise NotImplementedError
          # out = InplaceShift.apply(x, fold)
      else:
          out = torch.zeros_like(x)
          out[:, :-1, :fold] = x[:, 1:, :fold]  # shift left
          out[:, 1:, fold : 2 * fold] = x[
              :, :-1, fold : 2 * fold
          ]  # shift right
          out[:, :, 2 * fold :] = x[:, :, 2 * fold :]  # not shift
      return out.view(nt, c, h, w)
  
file_path: towhee/towhee/models/tsm/temporal_shift.py
imports: import torch
  from torch import nn
  import torch.nn.functional
  import torchvision
label_desc: Use image node_id 3 for calling the TemporalShift obj's underlying member method code with example usage: obj.shift(x, n_segment, fold_div, inplace) and returns: out