class_docstr: Matrix Transform abstract class. (Affine and Homography).
  Does all the transforms around the image /  center.
  
  Parameters
  ----------
  interpolation : str
      Interpolation mode.
  padding : str or None
      Padding Mode.
  p : float
      Probability of transform's execution.
  ignore_state : bool
      Whether to ignore the pre-calculated transformation or not. If False,
      then it will lead to an incorrect behavior when the objects are of different sizes.
      Should be used only when it is assumed that the image, mask and keypoints are of
      the same size.
class_docstr_tok: ["Matrix","Transform","abstract","class",".","(","Affine","and","Homography",")",".","Does","all","the","transforms","around","the","image","\/","center",".","Parameters","--","--","--","--","--","interpolation",":","str","Interpolation","mode",".","padding",":","str","or","None","Padding","Mode",".","p",":","float","Probability","of","transform","'s","execution",".","ignore_state",":","bool","Whether","to","ignore","the","pre-calculated","transformation","or","not",".","If","False",",","then","it","will","lead","to","an","incorrect","behavior","when","the","objects","are","of","different","sizes",".","Should","be","used","only","when","it","is","assumed","that","the","image",",","mask","and","keypoints","are","of","the","same","size","."]
docstr: Samples the transform and corrects for frame change.
  
  Returns
  -------
  None
code: def sample_transform(self, data):
      """
      Samples the transform and corrects for frame change.
  
      Returns
      -------
      None
  
      """
      super(MatrixTransform, self).sample_transform(data)
      self.sample_transform_matrix(
          data
      )  # Only this method needs to be implemented!
  
      # If we are in fast mode, we do not have to recompute the the new coordinate frame!
      if "P" not in data.data_format and not self.ignore_fast_mode:
          width = self.state_dict["w"]
          height = self.state_dict["h"]
          origin = [(width - 1) // 2, (height - 1) // 2]
          # First, let's make sure that our transformation matrix is applied at the origin
          transform_matrix_corr = (
              MatrixTransform.move_transform_to_origin(
                  self.state_dict["transform_matrix"], origin
              )
          )
          self.state_dict["h_new"], self.state_dict["w_new"] = (
              self.state_dict["h"],
              self.state_dict["w"],
          )
          self.state_dict[
              "transform_matrix_corrected"
          ] = transform_matrix_corr
      else:
          # If we have the keypoints or the transform is a homographic one, we can't use the fast mode at all.
          self.correct_transform()
  
imports: import copy
  import random
  from abc import ABCMeta, abstractmethod
  import cv2
  import numpy
  from solt.utils import Serializable
  from solt.constants import ALLOWED_INTERPOLATIONS, ALLOWED_PADDINGS
  from ._data import DataContainer, Keypoints
  from solt.utils import img_shape_checker, validate_parameter
label_desc: Use image node_id 4 for calling the MatrixTransform obj's underlying member method code with example usage: obj.sample_transform(data) without return types