class_docstr: Generate a smooth field array by defining a smaller randomized field and then reinterpolating to the desired size.
  
  This exploits interpolation to create a smoothly varying field used for other applications. An initial randomized
  field is defined with `rand_size` dimensions with `pad` number of values padding it along each dimension using
  `pad_val` as the value. If `spatial_size` is given this is interpolated to that size, otherwise if None the random
  array is produced uninterpolated. The output is always a Pytorch tensor allocated on the specified device.
  
  Args:
      rand_size: size of the randomized field to start from
      pad: number of pixels/voxels along the edges of the field to pad with `pad_val`
      pad_val: value with which to pad field edges
      low: low value for randomized field
      high: high value for randomized field
      channels: number of channels of final output
      spatial_size: final output size of the array, None to produce original uninterpolated field
      mode: interpolation mode for resizing the field
      align_corners: if True align the corners when upsampling field
      device: Pytorch device to define field on
class_docstr_tok: ["Generate","a","smooth","field","array","by","defining","a","smaller","randomized","field","and","then","reinterpolating","to","the","desired","size",".","This","exploits","interpolation","to","create","a","smoothly","varying","field","used","for","other","applications",".","An","initial","randomized","field","is","defined","with","`","rand_size","`","dimensions","with","`","pad","`","number","of","values","padding","it","along","each","dimension","using","`","pad_val","`","as","the","value",".","If","`","spatial_size","`","is","given","this","is","interpolated","to","that","size",",","otherwise","if","None","the","random","array","is","produced","uninterpolated",".","The","output","is","always","a","Pytorch","tensor","allocated","on","the","specified","device",".","Args",":","rand_size",":","size","of","the","randomized","field","to","start","from","pad",":","number","of","pixels\/voxels","along","the","edges","of","the","field","to","pad","with","`","pad_val","`","pad_val",":","value","with","which","to","pad","field","edges","low",":","low","value","for","randomized","field","high",":","high","value","for","randomized","field","channels",":","number","of","channels","of","final","output","spatial_size",":","final","output","size","of","the","array",",","None","to","produce","original","uninterpolated","field","mode",":","interpolation","mode","for","resizing","the","field","align_corners",":","if","True","align","the","corners","when","upsampling","field","device",":","Pytorch","device","to","define","field","on"]
code: def __init__(
      self,
      rand_size: Sequence[int],
      pad: int = 0,
      pad_val: float = 0,
      low: float = -1.0,
      high: float = 1.0,
      channels: int = 1,
      spatial_size: Sequence[int] | None = None,
      mode: str = InterpolateMode.AREA,
      align_corners: bool | None = None,
      device: torch.device | None = None,
  ):
      self.rand_size = tuple(rand_size)
      self.pad = pad
      self.low = low
      self.high = high
      self.channels = channels
      self.mode = mode
      self.align_corners = align_corners
      self.device = device
  
      self.spatial_size: Sequence[int] | None = None
      self.spatial_zoom: Sequence[float] | None = None
  
      if low >= high:
          raise ValueError(
              "Value for `low` must be less than `high` otherwise field will be zeros"
          )
  
      self.total_rand_size = tuple(
          rs + self.pad * 2 for rs in self.rand_size
      )
  
      self.field = (
          torch.ones(
              (1, self.channels) + self.total_rand_size,
              device=self.device,
          )
          * pad_val
      )
  
      self.crand_size = (self.channels,) + self.rand_size
  
      pad_slice = (
          slice(None) if self.pad == 0 else slice(self.pad, -self.pad)
      )
      self.rand_slices = (0, slice(None)) + (pad_slice,) * len(
          self.rand_size
      )
  
      self.set_spatial_size(spatial_size)
  
imports: from __future__ import annotations
  from collections.abc import Sequence
  from typing import Any
  import numpy
  import torch
  from torch.nn.functional import grid_sample, interpolate
  from monai.config.type_definitions import NdarrayOrTensor
  from monai.data.meta_obj import get_track_meta
  from monai.networks.utils import meshgrid_ij
  from monai.transforms.transform import Randomizable, RandomizableTransform
  from monai.transforms.utils_pytorch_numpy_unification import moveaxis
  from monai.utils import GridSampleMode, GridSamplePadMode, InterpolateMode
  from monai.utils.enums import TransformBackends
  from monai.utils.module import look_up_option
  from monai.utils.type_conversion import convert_to_dst_type, convert_to_tensor
label_desc: Use image node_id 1 to create a new SmoothField object from inherited base classes: Randomizable with example: obj = SmoothField(rand_size, pad, pad_val, low, high, channels, spatial_size, mode, align_corners, device)