@classmethod
def crop(cls, inputs, resize_to, data_format='channels_last'):
    """ Crop input tensor to a shape of a given image.
        If resize_to does not have a fully defined shape (resize_to.get_shape() has at least one None),
        the returned tf.Tensor will be of unknown shape except the number of channels.

        Parameters
        ----------
        inputs : tf.Tensor
            input tensor
        resize_to : tf.Tensor
            a tensor which shape the inputs should be resized to
        data_format : str {'channels_last', 'channels_first'}
            data format
        """
    static_shape = cls.spatial_shape(resize_to, data_format, False)
    dynamic_shape = cls.spatial_shape(resize_to, data_format, True)
    if None in cls.shape(inputs) + static_shape:
        return cls._dynamic_crop(inputs, static_shape, dynamic_shape,
            data_format)
    return cls._static_crop(inputs, static_shape, data_format)
