class_docstr: LIT WSGI application.
class_docstr_tok: ["LIT","WSGI","application","."]
docstr: Generate new datapoints based on the request.
docstr_tok: ["Generate","new","datapoints","based","on","the","request","."]
code: def _get_generated(
      self,
      data: types.JsonDict,
      model: Optional[str] = None,
      dataset_name: Optional[str] = None,
      generator: Optional[str] = None,
      **unused_kw,
  ):
      """Generate new datapoints based on the request."""
      if dataset_name is None:
          raise ValueError(
              'Must provide a "dataset_name" to get base examples.'
          )
      if generator is None:
          raise ValueError(
              'Must provide a "generator" name to generate examples.'
          )
      if model is None:
          raise ValueError(
              'Must provide a "model" name to get predictions.'
          )
  
      genny: lit_components.Generator = self._generators[generator]
      config_spec: types.Spec = genny.config_spec()
      config: Optional[types.JsonDict] = data.get("config")
  
      if config_spec and config is not None:
          utils.validate_config_against_spec(
              config,
              config_spec,
              f"{generator} ({type(genny).__name__})",
          )
  
      dataset = self._datasets[dataset_name]
      # Nested list, containing generated examples from each input.
      all_generated: list[
          list[Input]
      ] = genny.run(  # pytype: disable=annotation-type-mismatch  # always-use-return-annotations
          [ex["data"] for ex in data["inputs"]],
          self._models[model],
          dataset,
          config=config,
      )
  
      # Annotate datapoints
      def annotate_generated(datapoints):
          dataset_to_annotate = lit_dataset.Dataset(
              base=dataset, examples=datapoints
          )
          annotated_dataset = self._run_annotators(dataset_to_annotate)
          return annotated_dataset.examples
  
      annotated_generated = [
          annotate_generated(generated) for generated in all_generated
      ]
  
      # Add metadata.
      all_generated_indexed: list[list[IndexedInput]] = [
          dataset.index_inputs(generated)
          for generated in annotated_generated
      ]
      for parent, indexed_generated in zip(
          data["inputs"], all_generated_indexed
      ):
          for generated in indexed_generated:
              generated["meta"].update(
                  {
                      "parentId": parent["id"],
                      "source": generator,
                      "added": True,
                  }
              )
      return all_generated_indexed
  
imports: from collections.abc import Callable, Iterable, Mapping, Sequence
  import functools
  import glob
  import math
  import os
  import random
  import threading
  import time
  from typing import Any, Optional, TypedDict, Union
  from absl import logging
  from lit_nlp.api import components
  from lit_nlp.api import dataset
  from lit_nlp.api import layout
  from lit_nlp.api import model
  from lit_nlp.api import types
  from lit_nlp.components import core
  from lit_nlp.lib import caching
  from lit_nlp.lib import flag_helpers
  from lit_nlp.lib import serialize
  from lit_nlp.lib import ui_state
  from lit_nlp.lib import utils
  from lit_nlp.lib import validation
  from lit_nlp.lib import wsgi_app
  import tqdm
label_desc: Use image node_id 15 for calling the LitApp obj's underlying member method code with example usage: obj._get_generated(data, model, dataset_name, generator) and returns: all_generated_indexed, annotated_dataset