class_docstr: Prepare image data for the model specified by "prefix". For multiple models requiring image data,
  we need to create a ImageProcessor for each related model so that they will have independent input.
class_docstr_tok: ["Prepare","image","data","for","the","model","specified","by","``","prefix","''",".","For","multiple","models","requiring","image","data",",","we","need","to","create","a","ImageProcessor","for","each","related","model","so","that","they","will","have","independent","input","."]
docstr: Parameters
  ----------
  model
      The model for which this processor would be created.
  train_transforms
      A list of image transforms used in training. Note that the transform order matters.
  val_transforms
      A list of image transforms used in validation/test/prediction. Note that the transform order matters.
  norm_type
      How to normalize an image. We now support:
      - inception
          Normalize image by IMAGENET_INCEPTION_MEAN and IMAGENET_INCEPTION_STD from timm
      - imagenet
          Normalize image by IMAGENET_DEFAULT_MEAN and IMAGENET_DEFAULT_STD from timm
      - clip
          Normalize image by mean (0.48145466, 0.4578275, 0.40821073) and
          std (0.26862954, 0.26130258, 0.27577711), used for CLIP.
  size
      The provided width / height of a square image.
  max_img_num_per_col
      The maximum number of images one sample can have.
  missing_value_strategy
      How to deal with a missing image. We now support:
      - skip
          Skip this sample
      -zero
          Use an image with zero pixels.
  requires_column_info
      Whether to require feature column information in dataloader.
docstr_tok: ["Parameters","--","--","--","--","--","model","The","model","for","which","this","processor","would","be","created",".","train_transforms","A","list","of","image","transforms","used","in","training",".","Note","that","the","transform","order","matters",".","val_transforms","A","list","of","image","transforms","used","in","validation\/test\/prediction",".","Note","that","the","transform","order","matters",".","norm_type","How","to","normalize","an","image",".","We","now","support",":","-","inception","Normalize","image","by","IMAGENET_INCEPTION_MEAN","and","IMAGENET_INCEPTION_STD","from","timm","-","imagenet","Normalize","image","by","IMAGENET_DEFAULT_MEAN","and","IMAGENET_DEFAULT_STD","from","timm","-","clip","Normalize","image","by","mean","(","0.48145466",",","0.4578275",",","0.40821073",")","and","std","(","0.26862954",",","0.26130258",",","0.27577711",")",",","used","for","CLIP",".","size","The","provided","width","\/","height","of","a","square","image",".","max_img_num_per_col","The","maximum","number","of","images","one","sample","can","have",".","missing_value_strategy","How","to","deal","with","a","missing","image",".","We","now","support",":","-","skip","Skip","this","sample","-zero","Use","an","image","with","zero","pixels",".","requires_column_info","Whether","to","require","feature","column","information","in","dataloader","."]
code: def __init__(
      self,
      model: nn.Module,
      train_transforms: Union[List[str], Callable, List[Callable]],
      val_transforms: Union[List[str], Callable, List[Callable]],
      norm_type: Optional[str] = None,
      size: Optional[int] = None,
      max_img_num_per_col: Optional[int] = 1,
      missing_value_strategy: Optional[str] = "zero",
      requires_column_info: bool = False,
  ):
      """
      Parameters
      ----------
      model
          The model for which this processor would be created.
      train_transforms
          A list of image transforms used in training. Note that the transform order matters.
      val_transforms
          A list of image transforms used in validation/test/prediction. Note that the transform order matters.
      norm_type
          How to normalize an image. We now support:
          - inception
              Normalize image by IMAGENET_INCEPTION_MEAN and IMAGENET_INCEPTION_STD from timm
          - imagenet
              Normalize image by IMAGENET_DEFAULT_MEAN and IMAGENET_DEFAULT_STD from timm
          - clip
              Normalize image by mean (0.48145466, 0.4578275, 0.40821073) and
              std (0.26862954, 0.26130258, 0.27577711), used for CLIP.
      size
          The provided width / height of a square image.
      max_img_num_per_col
          The maximum number of images one sample can have.
      missing_value_strategy
          How to deal with a missing image. We now support:
          - skip
              Skip this sample
          -zero
              Use an image with zero pixels.
      requires_column_info
          Whether to require feature column information in dataloader.
      """
      self.train_transforms = train_transforms
      self.val_transforms = val_transforms
      logger.debug(
          f"image training transforms: {self.train_transforms}"
      )
      logger.debug(
          f"image validation transforms: {self.val_transforms}"
      )
  
      self.prefix = model.prefix
      self.missing_value_strategy = missing_value_strategy
      self.requires_column_info = requires_column_info
      self.size = None
      self.mean = None
      self.std = None
  
      if model is not None:
          self.size, self.mean, self.std = self.extract_default(
              model.config
          )
          if isinstance(model, TimmAutoModelForImagePrediction):
              if (
                  model.support_variable_input_size()
                  and size is not None
              ):
                  # We have detected that the model supports using an image size that is
                  # different from the pretrained model, e.g., ConvNets with global pooling
                  if size < self.size:
                      logger.warning(
                          f"The provided image size={size} is smaller than the default size "
                          f"of the pretrained backbone, which is {self.size}. "
                          f"Detailed configuration of the backbone is in {model.config}. "
                          f"You may like to double check your configuration."
                      )
                  self.size = size
          elif size is not None and size != self.size:
              logger.warning(
                  f"The model does not support using an image size that is different from the default size. "
                  f"Provided image size={size}. Default size={self.size}. "
                  f"Detailed model configuration={model.config}. We have ignored the provided image size."
              )
      if self.size is None:
          if size is not None:
              self.size = size
              logger.debug(f"using provided image size: {self.size}")
          else:
              raise ValueError("image size is missing")
      else:
          logger.debug(f"using detected image size: {self.size}")
      if self.mean is None or self.std is None:
          if norm_type is not None:
              self.mean, self.std = image_mean_std(norm_type)
              logger.debug(f"using provided normalization: {norm_type}")
          else:
              raise ValueError(
                  "image normalization mean and std are missing"
              )
      else:
          logger.debug(
              f"using detected image normalization: {self.mean} and {self.std}"
          )
      self.normalization = transforms.Normalize(self.mean, self.std)
      self.max_img_num_per_col = max_img_num_per_col
      if max_img_num_per_col <= 0:
          logger.debug(
              f"max_img_num_per_col {max_img_num_per_col} is reset to 1"
          )
          max_img_num_per_col = 1
      self.max_img_num_per_col = max_img_num_per_col
      logger.debug(f"max_img_num_per_col: {max_img_num_per_col}")
  
      self.train_processor = construct_image_processor(
          image_transforms=self.train_transforms,
          size=self.size,
          normalization=self.normalization,
      )
      self.val_processor = construct_image_processor(
          image_transforms=self.val_transforms,
          size=self.size,
          normalization=self.normalization,
      )
  
imports: import ast
  import logging
  import warnings
  from io import BytesIO
  from typing import Callable, Dict, List, Optional, Union
  import numpy
  import PIL
  import torch
  from omegaconf import ListConfig
  from PIL import ImageFile
  from torch import nn
  from torchvision import transforms
  from .utils import construct_image_processor, image_mean_std
  from ..constants import AUTOMM, CLIP, CLIP_IMAGE_MEAN, CLIP_IMAGE_STD, COLUMN, IMAGE, IMAGE_BYTEARRAY, IMAGE_PATH, IMAGE_VALID_NUM, TIMM_IMAGE
  from ..models.timm_image import TimmAutoModelForImagePrediction
  from .collator import PadCollator, StackCollator
  from .utils import extract_value_from_config
label_desc: Use image node_id 1 to create a new ImageProcessor object  with example: obj = ImageProcessor(model, train_transforms, val_transforms, norm_type, size, max_img_num_per_col, missing_value_strategy, requires_column_info)