class_docstr: This class allow the user to run multiple query with multiple prompts for a model.
  
  At the moment, we just support the SAM model. The model is loaded based on the given config.
  
  For default the images are transformed to have their long side with size of the `image_encoder.img_size`. This
  Prompter class ensure to transform the images and the prompts before prediction. Also, the image is passed
  automatically for the method `preprocess_image`, which is responsible for normalize the image and pad it to have
  the right size for the SAM model :math:`(   ext{image_encoder.img_size},    ext{image_encoder.img_size})`. For
  default the image is normalized by the mean and standard deviation of the SAM dataset values.
  
  Args:
      config: A model config to generate the model. Now just the SAM model is supported.
      device: The desired device to use the model.
      dtype: The desired dtype to use the model.
  
  Example:
      >>> # prompter = VisualPrompter() # Will load the vit h for default
      >>> # You can load a custom SAM type for modifying the config
      >>> prompter = VisualPrompter(SamConfig('vit_b'))
      >>> image = torch.rand(3, 25, 30)
      >>> prompter.set_image(image)
      >>> boxes = Boxes(
      ...    torch.tensor(
      ...         [[[[0, 0], [0, 10], [10, 0], [10, 10]]]],
      ...         device=prompter.device,
      ...         dtype=torch.float32
      ...    ),
      ...    mode='xyxy'
      ... )
      >>> prediction = prompter.predict(boxes=boxes)
      >>> prediction.logits.shape
      torch.Size([1, 3, 256, 256])
class_docstr_tok: ["This","class","allow","the","user","to","run","multiple","query","with","multiple","prompts","for","a","model",".","At","the","moment",",","we","just","support","the","SAM","model",".","The","model","is","loaded","based","on","the","given","config",".","For","default","the","images","are","transformed","to","have","their","long","side","with","size","of","the","`","image_encoder.img_size","`",".","This","Prompter","class","ensure","to","transform","the","images","and","the","prompts","before","prediction",".","Also",",","the","image","is","passed","automatically","for","the","method","`","preprocess_image","`",",","which","is","responsible","for","normalize","the","image","and","pad","it","to","have","the","right","size","for","the","SAM","model",":","math",":","`","(","ext","{","image_encoder.img_size","}",",","ext","{","image_encoder.img_size","}",")","`",".","For","default","the","image","is","normalized","by","the","mean","and","standard","deviation","of","the","SAM","dataset","values",".","Args",":","config",":","A","model","config","to","generate","the","model",".","Now","just","the","SAM","model","is","supported",".","device",":","The","desired","device","to","use","the","model",".","dtype",":","The","desired","dtype","to","use","the","model",".","Example",":",">",">",">","#","prompter","=","VisualPrompter","(",")","#","Will","load","the","vit","h","for","default",">",">",">","#","You","can","load","a","custom","SAM","type","for","modifying","the","config",">",">",">","prompter","=","VisualPrompter","(","SamConfig","(","'vit_b","'",")",")",">",">",">","image","=","torch.rand","(","3",",","25",",","30",")",">",">",">","prompter.set_image","(","image",")",">",">",">","boxes","=","Boxes","(","...","torch.tensor","(","...","[","[","[","[","0",",","0","]",",","[","0",",","10","]",",","[","10",",","0","]",",","[","10",",","10","]","]","]","]",",","...","device=prompter.device",",","...","dtype=torch.float32","...",")",",","...","mode='xyxy'","...",")",">",">",">","prediction","=","prompter.predict","(","boxes=boxes",")",">",">",">","prediction.logits.shape","torch.Size","(","[","1",",","3",",","256",",","256","]",")"]
docstr: Predict masks for the given image based on the input prompts.
  
  Args:
      keypoints: Point prompts to the model. Each point is in (X,Y) in pixels. Shape :math:`(K, N, 2)`. Where
                 `N` is the number of points and `K` the number of prompts.
      keypoint_labels: Labels for the point prompts. 1 indicates a foreground point and 0 indicates a background
                       point. Shape :math:`(K, N)`. Where `N` is the number of points, and `K` the number of
                       prompts.
      boxes: A box prompt to the model. If a tensor, should be in a xyxy mode. Shape :math:`(K, 4)`
      masks: A low resolution mask input to the model, typically coming from a previous prediction
             iteration. Has shape :math:`(K, 1, H, W)`, where for SAM, H=W=256.
      multimask_output: If true, the model will return three masks. For ambiguous input prompts (such as a
                        single click), this will often produce better masks than a single prediction. If only
                        a single mask is needed, the model's predicted quality score can be used to select the
                        best mask. For non-ambiguous prompts, such as multiple input prompts,
                        multimask_output=False can give better results.
      output_original_size: If true, the logits of `SegmentationResults` will be post-process to match the
                            original input image size.
  Returns:
      A prediction with the logits and scores (IoU of each predicted mask)
docstr_tok: ["Predict","masks","for","the","given","image","based","on","the","input","prompts",".","Args",":","keypoints",":","Point","prompts","to","the","model",".","Each","point","is","in","(","X",",","Y",")","in","pixels",".","Shape",":","math",":","`","(","K",",","N",",","2",")","`",".","Where","`","N","`","is","the","number","of","points","and","`","K","`","the","number","of","prompts",".","keypoint_labels",":","Labels","for","the","point","prompts",".","1","indicates","a","foreground","point","and","0","indicates","a","background","point",".","Shape",":","math",":","`","(","K",",","N",")","`",".","Where","`","N","`","is","the","number","of","points",",","and","`","K","`","the","number","of","prompts",".","boxes",":","A","box","prompt","to","the","model",".","If","a","tensor",",","should","be","in","a","xyxy","mode",".","Shape",":","math",":","`","(","K",",","4",")","`","masks",":","A","low","resolution","mask","input","to","the","model",",","typically","coming","from","a","previous","prediction","iteration",".","Has","shape",":","math",":","`","(","K",",","1",",","H",",","W",")","`",",","where","for","SAM",",","H=W=256",".","multimask_output",":","If","true",",","the","model","will","return","three","masks",".","For","ambiguous","input","prompts","(","such","as","a","single","click",")",",","this","will","often","produce","better","masks","than","a","single","prediction",".","If","only","a","single","mask","is","needed",",","the","model","'s","predicted","quality","score","can","be","used","to","select","the","best","mask",".","For","non-ambiguous","prompts",",","such","as","multiple","input","prompts",",","multimask_output=False","can","give","better","results",".","output_original_size",":","If","true",",","the","logits","of","`","SegmentationResults","`","will","be","post-process","to","match","the","original","input","image","size",".","Returns",":","A","prediction","with","the","logits","and","scores","(","IoU","of","each","predicted","mask",")"]
code: def predict(
      self,
      keypoints: Optional[Keypoints | Tensor] = None,
      keypoints_labels: Optional[Tensor] = None,
      boxes: Optional[Boxes | Tensor] = None,
      masks: Optional[Tensor] = None,
      multimask_output: bool = True,
      output_original_size: bool = True,
  ) -> SegmentationResults:
      """Predict masks for the given image based on the input prompts.
  
      Args:
          keypoints: Point prompts to the model. Each point is in (X,Y) in pixels. Shape :math:`(K, N, 2)`. Where
                     `N` is the number of points and `K` the number of prompts.
          keypoint_labels: Labels for the point prompts. 1 indicates a foreground point and 0 indicates a background
                           point. Shape :math:`(K, N)`. Where `N` is the number of points, and `K` the number of
                           prompts.
          boxes: A box prompt to the model. If a tensor, should be in a xyxy mode. Shape :math:`(K, 4)`
          masks: A low resolution mask input to the model, typically coming from a previous prediction
                 iteration. Has shape :math:`(K, 1, H, W)`, where for SAM, H=W=256.
          multimask_output: If true, the model will return three masks. For ambiguous input prompts (such as a
                            single click), this will often produce better masks than a single prediction. If only
                            a single mask is needed, the model's predicted quality score can be used to select the
                            best mask. For non-ambiguous prompts, such as multiple input prompts,
                            multimask_output=False can give better results.
          output_original_size: If true, the logits of `SegmentationResults` will be post-process to match the
                                original input image size.
      Returns:
          A prediction with the logits and scores (IoU of each predicted mask)
      """
  
      KORNIA_CHECK(
          self.is_image_set,
          "An image must be set with `self.set_image(...)` before `predict` be called!",
      )
  
      prompts = self.preprocess_prompts(
          keypoints, keypoints_labels, boxes, masks
      )
  
      # Embed prompts
      sparse_embeddings, dense_embeddings = self.model.prompt_encoder(
          points=prompts.points,
          boxes=prompts.boxes,
          masks=prompts.masks,
      )
      del prompts
  
      # Predict masks
      logits, scores = self.model.mask_decoder(
          image_embeddings=self.image_embeddings,
          image_pe=self.model.prompt_encoder.get_dense_pe(),
          sparse_prompt_embeddings=sparse_embeddings,
          dense_prompt_embeddings=dense_embeddings,
          multimask_output=multimask_output,
      )
      results = SegmentationResults(logits, scores)
      if (
          output_original_size
          and isinstance(self._input_image_size, tuple)
          and isinstance(self._original_image_size, tuple)
      ):
          results.original_res_logits(
              self._input_image_size,
              self._original_image_size,
              self._input_encoder_size,
          )
  
      # results = results.squeeze(0)
  
      return results
  
imports: from __future__ import annotations
  from typing import Any, Optional
  import torch
  from kornia.augmentation import LongestMaxSize
  from kornia.augmentation.container.augment import AugmentationSequential
  from kornia.contrib.models import Prompts, SegmentationResults
  from kornia.contrib.models.sam import Sam, SamConfig
  from kornia.core import Tensor, pad, tensor
  from kornia.core.check import KORNIA_CHECK, KORNIA_CHECK_IS_TENSOR, KORNIA_CHECK_SHAPE
  from kornia.enhance import normalize
  from kornia.geometry.boxes import Boxes
  from kornia.geometry.keypoints import Keypoints
label_desc: Use image node_id 9 for calling the VisualPrompter obj's underlying member method code with example usage: obj.predict(keypoints, keypoints_labels, boxes, masks, multimask_output, output_original_size) and returns: results