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: Normalize and pad a tensor.
  
  For normalize the tensor: will prioritize the `mean` and `std` passed as argument, if None will use the default
  Sam Dataset values.
  
  For pad the tensor: Will pad the tensor into the right and bottom to match with the size of
  `self.model.image_encoder.img_size`
  
  Args:
      x: The image to be preprocessed
      mean: Mean for each channel.
      std: Standard deviations for each channel.
  
  Returns:
      The image preprocessed (normalized if has mean and str available and padded to encoder size)
docstr_tok: ["Normalize","and","pad","a","tensor",".","For","normalize","the","tensor",":","will","prioritize","the","`","mean","`","and","`","std","`","passed","as","argument",",","if","None","will","use","the","default","Sam","Dataset","values",".","For","pad","the","tensor",":","Will","pad","the","tensor","into","the","right","and","bottom","to","match","with","the","size","of","`","self.model.image_encoder.img_size","`","Args",":","x",":","The","image","to","be","preprocessed","mean",":","Mean","for","each","channel",".","std",":","Standard","deviations","for","each","channel",".","Returns",":","The","image","preprocessed","(","normalized","if","has","mean","and","str","available","and","padded","to","encoder","size",")"]
code: def preprocess_image(
      self,
      x: Tensor,
      mean: Optional[Tensor] = None,
      std: Optional[Tensor] = None,
  ) -> Tensor:
      """Normalize and pad a tensor.
  
      For normalize the tensor: will prioritize the `mean` and `std` passed as argument, if None will use the default
      Sam Dataset values.
  
      For pad the tensor: Will pad the tensor into the right and bottom to match with the size of
      `self.model.image_encoder.img_size`
  
      Args:
          x: The image to be preprocessed
          mean: Mean for each channel.
          std: Standard deviations for each channel.
  
      Returns:
          The image preprocessed (normalized if has mean and str available and padded to encoder size)
      """
  
      if isinstance(mean, Tensor) and isinstance(std, Tensor):
          x = normalize(x, mean, std)
      elif isinstance(self.pixel_mean, Tensor) and isinstance(
          self.pixel_std, Tensor
      ):
          x = normalize(x, self.pixel_mean, self.pixel_std)
  
      encoder_im_size = self.model.image_encoder.img_size
      pad_h = encoder_im_size - x.shape[-2]
      pad_w = encoder_im_size - x.shape[-1]
      x = pad(x, (0, pad_w, 0, pad_h))
  
      return x
  
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 2 for calling the VisualPrompter obj's underlying member method code with example usage: obj.preprocess_image(x, mean, std) and returns: x