class_docstr: Resample the input image tensor ``x`` at the ``coordinates``.
  Resampling is required if the coordinates do not correspond to exact
  pixels in the input image. The ``sampling_mode`` determines
  the algorithm used for resampling and computing the values.
  
  Parameters
  ----------
  x: tensor<[B, C, H1, W1], T>
      * Must be rank ``4``.
  coordinates: tensor<[B, H2, W2, 2], U>
      * Must be rank ``4``.
      * Coordinates are provided in the order ``(x, y)`` (i.e. ``(w, h)``).
      * The value of each output location ``output[b, c, h, w]`` is calculated
        by sampling from the input image ``x[b, c, :, :]``.
      * The pixel at the ``(x, y)`` location corresponds to the length-2
        vector: ``coordinates[b, h, w, :]``.
      * Coordinate (normalized or unnormalized) should be specified according
        to ``coordinates_mode``.
  sampling_mode: const<str>
      * Allowed values: ``"bilinear"`` , ``"nearest"``
  padding_mode: const<str>
      * Allowed values: ``"constant"``, ``"border"``, ``"reflection"``, ``"symmetric"``
      * Note that the following example is 1D case for brevity.
        The op supports only 2D image input.
      * If ``padding_mode == "constant"``:
         * The input image is assumed to be padded with the ``padding_value``.
         * For example: ``|1, 2, 3| -> |0, 0, 0, 1, 2, 3, 0, 0, 0|``
      * if ``padding_mode == "border"``:
         * The input image is assumed to be padded with the values replicated
           from the values at the edge. This is also referred to as the
           "clamped" or "replication" mode, since the padded values are
           clamped to the border values.
         * For example: ``|1, 2, 3| -> |1, 1, 1, 1, 2, 3, 3, 3, 3|``
      * If ``padding_mode == "reflection"``:
         * The border values are reflected, *not* including the values at the edge/border.
         * For example: ``|1, 2, 3| -> |2, 3, 2, 1, 2, 3, 2, 1, 2|``
      * If ``padding_mode == "symmetric"``:
         * Values are reflected, including the border/edge values.
         * For example: ``|1, 2, 3| -> |3, 2, 1 , 1, 2, 3, 3, 2, 1|``
  padding_value: const<T>
      * To be used only when ``padding_mode == "constant"``, ignored in other cases.
  coordinates_mode: const<str>
      * Allowed values: ``"unnormalized"``, ``"normalized_minus_one_to_one"``,
        ``"normalized_zero_to_one"``
      * If ``coordinates_mode == "unnormalized"``, the coordinates input values
        are interpreted to be in range ``[0, W - 1] / [0, H - 1]``, which
        corresponds to the in-image point.
      * If ``coordinates_mode == "normalized_minus_one_to_one"``,
        the in-image values are ``[-1, 1]``.
      * If ``coordinates_mode == "normalized_zero_to_one"``,
        in-image values are ``[0, 1]``.
      * For example, if ``coordinates_mode == "normalized_minus_one_to_one"``, the in range values are [-1, 1]. That is:
         * ``(-1, -1)``, i.e. ``(w=-1, h=-1)``, corresponds to the top-left pixel.
         * ``(1, -1)``, i.e. ``(w=1, h=-1)``, corresponds to the top-right pixel.
         * ``(-1, 1)``, i.e. ``(w=-1, h=1)``, corresponds to the bottom-left pixel.
         * ``(1, 1)``, i.e. ``(w=1, h=1)``, corresponds to the bottom-right pixel.
  align_corners: const<bool>
      * If ``align_corners == True``, the extrema coordinates correspond to the center of the first and last corner pixels.
      * If ``align_corners == False``, the extrema coordinates correspond to the edge of the first and last corner pixels.
  
  Returns
  -------
  tensor<[B, C, H2, W2], T>
  
  Attributes
  ----------
  T: fp16, fp32
  U: fp32, int32
class_docstr_tok: ["Resample","the","input","image","tensor","``","x","``","at","the","``","coordinates","``",".","Resampling","is","required","if","the","coordinates","do","not","correspond","to","exact","pixels","in","the","input","image",".","The","``","sampling_mode","``","determines","the","algorithm","used","for","resampling","and","computing","the","values",".","Parameters","--","--","--","--","--","x",":","tensor","<","[","B",",","C",",","H1",",","W1","]",",","T",">","*","Must","be","rank","``","4","``",".","coordinates",":","tensor","<","[","B",",","H2",",","W2",",","2","]",",","U",">","*","Must","be","rank","``","4","``",".","*","Coordinates","are","provided","in","the","order","``","(","x",",","y",")","``","(","i.e",".","``","(","w",",","h",")","``",")",".","*","The","value","of","each","output","location","``","output","[","b",",","c",",","h",",","w","]","``","is","calculated","by","sampling","from","the","input","image","``","x","[","b",",","c",",",":",",",":","]","``",".","*","The","pixel","at","the","``","(","x",",","y",")","``","location","corresponds","to","the","length-2","vector",":","``","coordinates","[","b",",","h",",","w",",",":","]","``",".","*","Coordinate","(","normalized","or","unnormalized",")","should","be","specified","according","to","``","coordinates_mode","``",".","sampling_mode",":","const","<","str",">","*","Allowed","values",":","``","``","bilinear","''","``",",","``","``","nearest","''","``","padding_mode",":","const","<","str",">","*","Allowed","values",":","``","``","constant","''","``",",","``","``","border","''","``",",","``","``","reflection","''","``",",","``","``","symmetric","''","``","*","Note","that","the","following","example","is","1D","case","for","brevity",".","The","op","supports","only","2D","image","input",".","*","If","``","padding_mode","==","``","constant","''","``",":","*","The","input","image","is","assumed","to","be","padded","with","the","``","padding_value","``",".","*","For","example",":","``","|1",",","2",",","3|","-",">","|0",",","0",",","0",",","1",",","2",",","3",",","0",",","0",",","0|","``","*","if","``","padding_mode","==","``","border","''","``",":","*","The","input","image","is","assumed","to","be","padded","with","the","values","replicated","from","the","values","at","the","edge",".","This","is","also","referred","to","as","the","``","clamped","''","or","``","replication","''","mode",",","since","the","padded","values","are","clamped","to","the","border","values",".","*","For","example",":","``","|1",",","2",",","3|","-",">","|1",",","1",",","1",",","1",",","2",",","3",",","3",",","3",",","3|","``","*","If","``","padding_mode","==","``","reflection","''","``",":","*","The","border","values","are","reflected",",","*","not","*","including","the","values","at","the","edge\/border",".","*","For","example",":","``","|1",",","2",",","3|","-",">","|2",",","3",",","2",",","1",",","2",",","3",",","2",",","1",",","2|","``","*","If","``","padding_mode","==","``","symmetric","''","``",":","*","Values","are","reflected",",","including","the","border\/edge","values",".","*","For","example",":","``","|1",",","2",",","3|","-",">","|3",",","2",",","1",",","1",",","2",",","3",",","3",",","2",",","1|","``","padding_value",":","const","<","T",">","*","To","be","used","only","when","``","padding_mode","==","``","constant","''","``",",","ignored","in","other","cases",".","coordinates_mode",":","const","<","str",">","*","Allowed","values",":","``","``","unnormalized","''","``",",","``","``","normalized_minus_one_to_one","''","``",",","``","``","normalized_zero_to_one","''","``","*","If","``","coordinates_mode","==","``","unnormalized","''","``",",","the","coordinates","input","values","are","interpreted","to","be","in","range","``","[","0",",","W","-","1","]","\/","[","0",",","H","-","1","]","``",",","which","corresponds","to","the","in-image","point",".","*","If","``","coordinates_mode","==","``","normalized_minus_one_to_one","''","``",",","the","in-image","values","are","``","[","-1",",","1","]","``",".","*","If","``","coordinates_mode","==","``","normalized_zero_to_one","''","``",",","in-image","values","are","``","[","0",",","1","]","``",".","*","For","example",",","if","``","coordinates_mode","==","``","normalized_minus_one_to_one","''","``",",","the","in","range","values","are","[","-1",",","1","]",".","That","is",":","*","``","(","-1",",","-1",")","``",",","i.e",".","``","(","w=-1",",","h=-1",")","``",",","corresponds","to","the","top-left","pixel",".","*","``","(","1",",","-1",")","``",",","i.e",".","``","(","w=1",",","h=-1",")","``",",","corresponds","to","the","top-right","pixel",".","*","``","(","-1",",","1",")","``",",","i.e",".","``","(","w=-1",",","h=1",")","``",",","corresponds","to","the","bottom-left","pixel",".","*","``","(","1",",","1",")","``",",","i.e",".","``","(","w=1",",","h=1",")","``",",","corresponds","to","the","bottom-right","pixel",".","align_corners",":","const","<","bool",">","*","If","``","align_corners","==","True","``",",","the","extrema","coordinates","correspond","to","the","center","of","the","first","and","last","corner","pixels",".","*","If","``","align_corners","==","False","``",",","the","extrema","coordinates","correspond","to","the","edge","of","the","first","and","last","corner","pixels",".","Returns","--","--","--","-","tensor","<","[","B",",","C",",","H2",",","W2","]",",","T",">","Attributes","--","--","--","--","--","T",":","fp16",",","fp32","U",":","fp32",",","int32"]
code: def type_inference(self):
      if self.x.rank != 4:
          raise ValueError(
              'input "x" to the "resample" op must be a rank 4 tensor. '
              "Got rank {} tensor of shape {}".format(
                  self.x.rank, self.x.shape
              )
          )
      if self.coordinates.rank != 4:
          raise ValueError(
              'input "coordinates" to the "resample" op must be a rank 4 tensor. '
              "Got rank {} tensor of shape {}".format(
                  self.coordinates.rank, self.coordinates.shape
              )
          )
  
      input_shape = self.x.shape
      coord_shape = self.coordinates.shape
      if (
          not is_symbolic(input_shape[0])
          and not is_symbolic(coord_shape[0])
          and input_shape[0] != coord_shape[0]
      ):
          raise ValueError(
              'input "x" and "coordinates" to the "resample" must agree on '
              "dimension of batch size: {} vs. {}".format(
                  input_shape[0], coord_shape[0]
              )
          )
      if not is_symbolic(coord_shape[-1]) and coord_shape[-1] != 2:
          raise ValueError(
              'input "coordinates" to the "resample" op last dimension must be 2. '
              "Got {} for last dimension".format(coord_shape[-1])
          )
  
      ret_shape = list(input_shape)
      ret_shape[2] = coord_shape[1]  # Output height
      ret_shape[3] = coord_shape[2]  # Output width
      return types.tensor(self.x.dtype, tuple(ret_shape))
  
imports: import numpy
  from coremltools.converters.mil.mil import DefaultInputs, InputSpec, Operation, TensorInputType, get_new_symbol, types
  from coremltools.converters.mil.mil.ops.defs._op_reqs import register_op
  from coremltools.converters.mil.mil.ops.defs.iOS15 import _IOS15_TARGET
  from coremltools.converters.mil.mil.types.symbolic import is_symbolic
label_desc: Use image node_id 1 for calling the resample obj's underlying member method code with example usage: obj.type_inference() and returns: types