class_docstr: Wraps model that uses index to retrieve image data for making
  predictions.
class_docstr_tok: ["Wraps","model","that","uses","index","to","retrieve","image","data","for","making","predictions","."]
docstr: Initialize the WrappedIndexPredictorModel.
  
  :param model: The model to wrap.
  :type model: object
  :param dataset: The dataset to use for making predictions.
  :type dataset: pandas.DataFrame
  :param image_mode: The mode to open the image in.
      See pillow documentation for all modes:
      https://pillow.readthedocs.io/en/stable/handbook/concepts.html
  :type image_mode: str
  :param transformations: The transformations to apply to the image.
  :type transformations: object
  :param task_type: The task to run.
  :type task_type: str
  :param classes: The classes for the model.
  :type classes: list
docstr_tok: ["Initialize","the","WrappedIndexPredictorModel",".",":","param","model",":","The","model","to","wrap",".",":","type","model",":","object",":","param","dataset",":","The","dataset","to","use","for","making","predictions",".",":","type","dataset",":","pandas.DataFrame",":","param","image_mode",":","The","mode","to","open","the","image","in",".","See","pillow","documentation","for","all","modes",":","https",":","\/\/pillow.readthedocs.io\/en\/stable\/handbook\/concepts.html",":","type","image_mode",":","str",":","param","transformations",":","The","transformations","to","apply","to","the","image",".",":","type","transformations",":","object",":","param","task_type",":","The","task","to","run",".",":","type","task_type",":","str",":","param","classes",":","The","classes","for","the","model",".",":","type","classes",":","list"]
code: def __init__(
      self,
      model,
      dataset,
      image_mode,
      transformations,
      task_type,
      classes=None,
  ):
      """Initialize the WrappedIndexPredictorModel.
  
      :param model: The model to wrap.
      :type model: object
      :param dataset: The dataset to use for making predictions.
      :type dataset: pandas.DataFrame
      :param image_mode: The mode to open the image in.
          See pillow documentation for all modes:
          https://pillow.readthedocs.io/en/stable/handbook/concepts.html
      :type image_mode: str
      :param transformations: The transformations to apply to the image.
      :type transformations: object
      :param task_type: The task to run.
      :type task_type: str
      :param classes: The classes for the model.
      :type classes: list
      """
      self.model = model
      self.dataset = dataset
      self.classes = classes
      self.image_mode = image_mode
      self.transformations = transformations
      self.task_type = task_type
      if is_automl_image_model(self.model):
          test = np.array(self.dataset.iloc[:, 0].tolist())
          if self.task_type == ModelTask.OBJECT_DETECTION:
              test = pd.DataFrame(
                  data=[
                      [
                          x
                          for x in get_base64_string_from_path(
                              img_path, return_image_size=True
                          )
                      ]
                      for img_path in test
                  ],
                  columns=[
                      MLFlowSchemaLiterals.INPUT_COLUMN_IMAGE,
                      MLFlowSchemaLiterals.INPUT_IMAGE_SIZE,
                  ],
              )
          else:
              test = pd.DataFrame(
                  data=[
                      get_base64_string_from_path(img_path)
                      for img_path in test
                  ],
                  columns=[MLFlowSchemaLiterals.INPUT_COLUMN_IMAGE],
              )
      else:
          test = get_images(
              self.dataset, self.image_mode, self.transformations
          )
      self.predictions = self.model.predict(test)
      if task_type == ModelTask.MULTILABEL_IMAGE_CLASSIFICATION:
          predictions_joined = []
          for row in self.predictions:
              # get all labels where prediction is 1
              pred_labels = [i for i in range(len(row)) if row[i]]
              if self.classes is not None:
                  pred_labels = [self.classes[i] for i in pred_labels]
              else:
                  pred_labels = [str(i) for i in pred_labels]
              # concatenate all predicted labels into a single string
              predictions_joined.append(",".join(pred_labels))
          self.predictions = np.array(predictions_joined)
      self.predict_proba = self.model.predict_proba(test)
  
imports: import json
  from typing import Any, List, Optional
  import jsonschema
  import numpy
  import pandas
  from ml_wrappers import wrap_model
  from erroranalysis._internal.error_analyzer import ModelAnalyzer
  from erroranalysis._internal.error_report import as_error_report
  from responsibleai._tools.shared.state_directory_management import DirectoryManager
  from responsibleai.managers.error_analysis_manager import ErrorAnalysisManager
  from responsibleai.managers.error_analysis_manager import as_error_config
  from responsibleai_vision.common.constants import MLFlowSchemaLiterals, ModelTask
  from responsibleai_vision.utils.image_reader import get_base64_string_from_path, is_automl_image_model
  from responsibleai_vision.utils.image_utils import get_images
label_desc: Use image node_id 1 to create a new WrappedIndexPredictorModel object  with example: obj = WrappedIndexPredictorModel(model, dataset, image_mode, transformations, task_type, classes)