class_docstr: Logs validation data as a wandb.Table.
  
  ValidationDataLogger is intended to be used inside of library integrations
  in order to facilitate the process of optionally building a validation dataset
  and logging periodic predictions against such validation data using WandB best
  practices.
docstr: Initialize a new ValidationDataLogger.
  
  Args:
      inputs: A list of input vectors or dictionary of lists of input vectors
          (used if the model has multiple named inputs)
      targets: A list of target vectors or dictionary of lists of target vectors
          (used if the model has multiple named targets/putputs). Defaults to `None`.
          `targets` and `indexes` cannot both be `None`.
      indexes: An ordered list of `wandb.data_types._TableIndex` mapping the
          input items to their source table. This is most commonly retrieved by using
          `indexes = my_data_table.get_index()`. Defaults to `None`. `targets`
          and `indexes` cannot both be `None`.
      validation_row_processor: A function to apply to the validation data,
          commonly used to visualize the data. The function will receive an `ndx` (`int`)
          and a `row` (`dict`). If `inputs` is a list, then `row["input"]` will be the input
          data for the row. Else, it will be keyed based on the name of the input slot
          (corresponding to `inputs`). If `targets` is a list, then
          `row["target"]` will be the target data for the row. Else, it will
          be keyed based on `targets`. For example, if your input data is a
          single ndarray, but you wish to visualize the data as an image,
          then you can provide `lambda ndx, row: {"img": wandb.Image(row["input"])}`
          as the processor. If `None`, we will try to guess the appropriate processor.
          Ignored if `log_evaluation` is `False` or `val_keys` are present. Defaults to `None`.
      prediction_row_processor: Same as validation_row_processor, but applied to the
          model's output. `row["output"]` will contain the results of the model output.
          Defaults to `None`.
      input_col_name: The name to use for the input column.
          Defaults to `"input"`.
      target_col_name: The name to use for the target column.
          Defaults to `"target"`.
      table_name: The name to use for the validation table.
          Defaults to `"wb_validation_data"`.
      artifact_type: The artifact type to use for the validation data.
          Defaults to `"validation_dataset"`.
      class_labels: Optional list of lables to use in the inferred
          processors. If the model's `target` or `output` is inferred to be a class,
          we will attempt to map the class to these labels. Defaults to `None`.
      infer_missing_processors: Determines if processors are inferred if
          they are missing. Defaults to True.
docstr_tok: ["Initialize","a","new","ValidationDataLogger",".","Args",":","inputs",":","A","list","of","input","vectors","or","dictionary","of","lists","of","input","vectors","(","used","if","the","model","has","multiple","named","inputs",")","targets",":","A","list","of","target","vectors","or","dictionary","of","lists","of","target","vectors","(","used","if","the","model","has","multiple","named","targets\/putputs",")",".","Defaults","to","`","None","`",".","`","targets","`","and","`","indexes","`","can","not","both","be","`","None","`",".","indexes",":","An","ordered","list","of","`","wandb.data_types._TableIndex","`","mapping","the","input","items","to","their","source","table",".","This","is","most","commonly","retrieved","by","using","`","indexes","=","my_data_table.get_index","(",")","`",".","Defaults","to","`","None","`",".","`","targets","`","and","`","indexes","`","can","not","both","be","`","None","`",".","validation_row_processor",":","A","function","to","apply","to","the","validation","data",",","commonly","used","to","visualize","the","data",".","The","function","will","receive","an","`","ndx","`","(","`","int","`",")","and","a","`","row","`","(","`","dict","`",")",".","If","`","inputs","`","is","a","list",",","then","`","row","[","``","input","''","]","`","will","be","the","input","data","for","the","row",".","Else",",","it","will","be","keyed","based","on","the","name","of","the","input","slot","(","corresponding","to","`","inputs","`",")",".","If","`","targets","`","is","a","list",",","then","`","row","[","``","target","''","]","`","will","be","the","target","data","for","the","row",".","Else",",","it","will","be","keyed","based","on","`","targets","`",".","For","example",",","if","your","input","data","is","a","single","ndarray",",","but","you","wish","to","visualize","the","data","as","an","image",",","then","you","can","provide","`","lambda","ndx",",","row",":","{","``","img","''",":","wandb.Image","(","row","[","``","input","''","]",")","}","`","as","the","processor",".","If","`","None","`",",","we","will","try","to","guess","the","appropriate","processor",".","Ignored","if","`","log_evaluation","`","is","`","False","`","or","`","val_keys","`","are","present",".","Defaults","to","`","None","`",".","prediction_row_processor",":","Same","as","validation_row_processor",",","but","applied","to","the","model","'s","output",".","`","row","[","``","output","''","]","`","will","contain","the","results","of","the","model","output",".","Defaults","to","`","None","`",".","input_col_name",":","The","name","to","use","for","the","input","column",".","Defaults","to","`","``","input","''","`",".","target_col_name",":","The","name","to","use","for","the","target","column",".","Defaults","to","`","``","target","''","`",".","table_name",":","The","name","to","use","for","the","validation","table",".","Defaults","to","`","``","wb_validation_data","''","`",".","artifact_type",":","The","artifact","type","to","use","for","the","validation","data",".","Defaults","to","`","``","validation_dataset","''","`",".","class_labels",":","Optional","list","of","lables","to","use","in","the","inferred","processors",".","If","the","model","'s","`","target","`","or","`","output","`","is","inferred","to","be","a","class",",","we","will","attempt","to","map","the","class","to","these","labels",".","Defaults","to","`","None","`",".","infer_missing_processors",":","Determines","if","processors","are","inferred","if","they","are","missing",".","Defaults","to","True","."]
code: def __init__(
      self,
      inputs: Union[Sequence, Dict[str, Sequence]],
      targets: Optional[Union[Sequence, Dict[str, Sequence]]] = None,
      indexes: Optional[List["_TableIndex"]] = None,
      validation_row_processor: Optional[Callable] = None,
      prediction_row_processor: Optional[Callable] = None,
      input_col_name: str = "input",
      target_col_name: str = "target",
      table_name: str = "wb_validation_data",
      artifact_type: str = "validation_dataset",
      class_labels: Optional[List[str]] = None,
      infer_missing_processors: bool = True,
  ) -> None:
      """Initialize a new ValidationDataLogger.
  
      Args:
          inputs: A list of input vectors or dictionary of lists of input vectors
              (used if the model has multiple named inputs)
          targets: A list of target vectors or dictionary of lists of target vectors
              (used if the model has multiple named targets/putputs). Defaults to `None`.
              `targets` and `indexes` cannot both be `None`.
          indexes: An ordered list of `wandb.data_types._TableIndex` mapping the
              input items to their source table. This is most commonly retrieved by using
              `indexes = my_data_table.get_index()`. Defaults to `None`. `targets`
              and `indexes` cannot both be `None`.
          validation_row_processor: A function to apply to the validation data,
              commonly used to visualize the data. The function will receive an `ndx` (`int`)
              and a `row` (`dict`). If `inputs` is a list, then `row["input"]` will be the input
              data for the row. Else, it will be keyed based on the name of the input slot
              (corresponding to `inputs`). If `targets` is a list, then
              `row["target"]` will be the target data for the row. Else, it will
              be keyed based on `targets`. For example, if your input data is a
              single ndarray, but you wish to visualize the data as an image,
              then you can provide `lambda ndx, row: {"img": wandb.Image(row["input"])}`
              as the processor. If `None`, we will try to guess the appropriate processor.
              Ignored if `log_evaluation` is `False` or `val_keys` are present. Defaults to `None`.
          prediction_row_processor: Same as validation_row_processor, but applied to the
              model's output. `row["output"]` will contain the results of the model output.
              Defaults to `None`.
          input_col_name: The name to use for the input column.
              Defaults to `"input"`.
          target_col_name: The name to use for the target column.
              Defaults to `"target"`.
          table_name: The name to use for the validation table.
              Defaults to `"wb_validation_data"`.
          artifact_type: The artifact type to use for the validation data.
              Defaults to `"validation_dataset"`.
          class_labels: Optional list of lables to use in the inferred
              processors. If the model's `target` or `output` is inferred to be a class,
              we will attempt to map the class to these labels. Defaults to `None`.
          infer_missing_processors: Determines if processors are inferred if
              they are missing. Defaults to True.
      """
      class_labels_table: Optional[wandb.Table]
      if isinstance(class_labels, list) and len(class_labels) > 0:
          class_labels_table = wandb.Table(
              columns=["label"],
              data=[[label] for label in class_labels],
          )
      else:
          class_labels_table = None
  
      if indexes is None:
          assert targets is not None
          local_validation_table = wandb.Table(columns=[], data=[])
  
          if isinstance(targets, dict):
              for col_name in targets:
                  local_validation_table.add_column(
                      col_name, targets[col_name]
                  )
          else:
              local_validation_table.add_column(
                  target_col_name, targets
              )
  
          if isinstance(inputs, dict):
              for col_name in inputs:
                  local_validation_table.add_column(
                      col_name, inputs[col_name]
                  )
          else:
              local_validation_table.add_column(input_col_name, inputs)
  
          if (
              validation_row_processor is None
              and infer_missing_processors
          ):
              example_input = _make_example(inputs)
              example_target = _make_example(targets)
              if (
                  example_input is not None
                  and example_target is not None
              ):
                  validation_row_processor = (
                      _infer_validation_row_processor(
                          example_input,
                          example_target,
                          class_labels_table,
                          input_col_name,
                          target_col_name,
                      )
                  )
  
          if validation_row_processor is not None:
              local_validation_table.add_computed_columns(
                  validation_row_processor
              )
  
          local_validation_artifact = wandb.Artifact(
              table_name, artifact_type
          )
          local_validation_artifact.add(
              local_validation_table, "validation_data"
          )
          if wandb.run:
              wandb.run.use_artifact(local_validation_artifact)
          indexes = local_validation_table.get_index()
      else:
          local_validation_artifact = None
  
      self.class_labels_table = class_labels_table
      self.validation_inputs = inputs
      self.validation_targets = targets
      self.validation_indexes = indexes
      self.prediction_row_processor = prediction_row_processor
      self.infer_missing_processors = infer_missing_processors
      self.local_validation_artifact = local_validation_artifact
      self.input_col_name = input_col_name
  
file_path: wandb/wandb/sdk/integration_utils/data_logging.py
imports: import sys
  from collections.abc import Sequence
  from typing import TYPE_CHECKING, Any, Callable, Dict, List, Optional, Union
  import wandb
label_desc: Use image node_id 1 to create a new ValidationDataLogger object  with example: obj = ValidationDataLogger(inputs, targets, indexes, validation_row_processor, prediction_row_processor, input_col_name, target_col_name, table_name, artifact_type, class_labels, infer_missing_processors)