class_docstr: Warp an image with given dense displacement field (DDF).
class_docstr_tok: ["Warp","an","image","with","given","dense","displacement","field","(","DDF",")","."]
docstr: For pytorch native APIs, the possible values are:
  
      - mode: ``"nearest"``, ``"bilinear"``, ``"bicubic"``.
      - padding_mode: ``"zeros"``, ``"border"``, ``"reflection"``
  
  See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.grid_sample.html
  
  For MONAI C++/CUDA extensions, the possible values are:
  
      - mode: ``"nearest"``, ``"bilinear"``, ``"bicubic"``, 0, 1, ...
      - padding_mode: ``"zeros"``, ``"border"``, ``"reflection"``, 0, 1, ...
  
  See also: :py:class:`monai.networks.layers.grid_pull`
  
  - jitter: bool, default=False
      Define reference grid on non-integer values
      Reference: B. Likar and F. Pernus. A heirarchical approach to elastic registration
      based on mutual information. Image and Vision Computing, 19:33-44, 2001.
docstr_tok: ["For","pytorch","native","APIs",",","the","possible","values","are",":","-","mode",":","``","``","nearest","''","``",",","``","``","bilinear","''","``",",","``","``","bicubic","''","``",".","-","padding_mode",":","``","``","zeros","''","``",",","``","``","border","''","``",",","``","``","reflection","''","``","See","also",":","https",":","\/\/pytorch.org\/docs\/stable\/generated\/torch.nn.functional.grid_sample.html","For","MONAI","C++\/CUDA","extensions",",","the","possible","values","are",":","-","mode",":","``","``","nearest","''","``",",","``","``","bilinear","''","``",",","``","``","bicubic","''","``",",","0",",","1",",","...","-","padding_mode",":","``","``","zeros","''","``",",","``","``","border","''","``",",","``","``","reflection","''","``",",","0",",","1",",","...","See","also",":",":","py",":","class",":","`","monai.networks.layers.grid_pull","`","-","jitter",":","bool",",","default=False","Define","reference","grid","on","non-integer","values","Reference",":","B.","Likar","and","F.","Pernus",".","A","heirarchical","approach","to","elastic","registration","based","on","mutual","information",".","Image","and","Vision","Computing",",","19:33-44",",","2001","."]
code: def __init__(
      self,
      mode=GridSampleMode.BILINEAR.value,
      padding_mode=GridSamplePadMode.BORDER.value,
      jitter=False,
  ):
      """
      For pytorch native APIs, the possible values are:
  
          - mode: ``"nearest"``, ``"bilinear"``, ``"bicubic"``.
          - padding_mode: ``"zeros"``, ``"border"``, ``"reflection"``
  
      See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.grid_sample.html
  
      For MONAI C++/CUDA extensions, the possible values are:
  
          - mode: ``"nearest"``, ``"bilinear"``, ``"bicubic"``, 0, 1, ...
          - padding_mode: ``"zeros"``, ``"border"``, ``"reflection"``, 0, 1, ...
  
      See also: :py:class:`monai.networks.layers.grid_pull`
  
      - jitter: bool, default=False
          Define reference grid on non-integer values
          Reference: B. Likar and F. Pernus. A heirarchical approach to elastic registration
          based on mutual information. Image and Vision Computing, 19:33-44, 2001.
      """
      super().__init__()
      # resolves _interp_mode for different methods
  
      if USE_COMPILED:
          if mode in (inter.value for inter in GridSampleMode):
              mode = GridSampleMode(mode)
              if mode == GridSampleMode.BILINEAR:
                  mode = 1
              elif mode == GridSampleMode.NEAREST:
                  mode = 0
              elif mode == GridSampleMode.BICUBIC:
                  mode = 3
              else:
                  mode = 1  # default to linear
          self._interp_mode = mode
      else:
          warnings.warn(
              "monai.networks.blocks.Warp: Using PyTorch native grid_sample."
          )
          self._interp_mode = GridSampleMode(mode).value
  
      # resolves _padding_mode for different methods
      if USE_COMPILED:
          if padding_mode in (pad.value for pad in GridSamplePadMode):
              padding_mode = GridSamplePadMode(padding_mode)
              if padding_mode == GridSamplePadMode.ZEROS:
                  padding_mode = 7
              elif padding_mode == GridSamplePadMode.BORDER:
                  padding_mode = 0
              elif padding_mode == GridSamplePadMode.REFLECTION:
                  padding_mode = 1
              else:
                  padding_mode = 0  # default to nearest
          self._padding_mode = padding_mode
      else:
          self._padding_mode = GridSamplePadMode(padding_mode).value
  
      self.ref_grid = None
      self.jitter = jitter
  
file_path: MONAI/monai/networks/blocks/warp.py
imports: from __future__ import annotations
  import warnings
  import torch
  from torch import nn
  from torch.nn import functional
  from monai.config.deviceconfig import USE_COMPILED
  from monai.networks.layers.spatial_transforms import grid_pull
  from monai.networks.utils import meshgrid_ij
  from monai.utils import GridSampleMode, GridSamplePadMode, optional_import
label_desc: Use image node_id 1 to create a new Warp object from inherited base classes: nn with example: obj = Warp(mode, padding_mode, jitter)