class_docstr: One-parameter logistic item-response theory (IRT) model.
  
  This models a set of students answering a set of questions, and being scored
  whether they get the question correct or not. Each student is associated
  with a scalar `centered_student_ability`, and each question is associated
  with a scalar `question_difficulty`. Additionally, a scalar
  `mean_student_ability` is shared between all the students. This corresponds
  to the [1PL item-response theory][1] model:
  
  ```none
  mean_student_ability ∼ N(loc=0.75, scale=1)
  
  for i in range(num_students):
    centered_student_ability[i] ∼ N(loc=0, scale=1)
  
  for j in range(num_questions):
    question_difficulty[j] = N(loc=0, scale=1)
  
  for i, j in student_question_pairs:
    correct[i, j] = Bernoulli(logit=centered_student_ability[i] -
                              question_difficulty[j] + mean_student_ability)
  ```
  
  The data are encoded into three parallel arrays per set. I.e.
  `*_correct[i]  == 1` means that student `*_student_ids[i]` answered question
  `*_question_ids[i]` correctly; `*_correct[i] == 0` means they didn't.
  
  #### References
  
  1. https://en.wikipedia.org/wiki/Item_response_theory
class_docstr_tok: ["One-parameter","logistic","item-response","theory","(","IRT",")","model",".","This","models","a","set","of","students","answering","a","set","of","questions",",","and","being","scored","whether","they","get","the","question","correct","or","not",".","Each","student","is","associated","with","a","scalar","`","centered_student_ability","`",",","and","each","question","is","associated","with","a","scalar","`","question_difficulty","`",".","Additionally",",","a","scalar","`","mean_student_ability","`","is","shared","between","all","the","students",".","This","corresponds","to","the","[","1PL","item-response","theory","]","[","1","]","model",":","``","`","none","mean_student_ability","\u223c","N","(","loc=0.75",",","scale=1",")","for","i","in","range","(","num_students",")",":","centered_student_ability","[","i","]","\u223c","N","(","loc=0",",","scale=1",")","for","j","in","range","(","num_questions",")",":","question_difficulty","[","j","]","=","N","(","loc=0",",","scale=1",")","for","i",",","j","in","student_question_pairs",":","correct","[","i",",","j","]","=","Bernoulli","(","logit=centered_student_ability","[","i","]","-","question_difficulty","[","j","]","+","mean_student_ability",")","``","`","The","data","are","encoded","into","three","parallel","arrays","per","set",".","I.e",".","`","*","_correct","[","i","]","==","1","`","means","that","student","`","*","_student_ids","[","i","]","`","answered","question","`","*","_question_ids","[","i","]","`","correctly",";","`","*","_correct","[","i","]","==","0","`","means","they","did","n't",".","#","#","#","#","References","1.","https",":","\/\/en.wikipedia.org\/wiki\/Item_response_theory"]
code: def _sparse_to_dense(self, student_ids, question_ids, correct):
      # TODO(siege): This probably should support batching, for completeness.
      # TODO(b/162452866): This should be rewritten via scatter_nd to support
      # tensor-valued datasets. Blocked by JAX/Numpy not implementing scatter_nd.
      dense_y = np.zeros(
          [self._num_students, self._num_questions], np.float32
      )
      dense_y[student_ids, question_ids] = correct
      y_mask = np.zeros(dense_y.shape, np.bool_)
      y_mask[student_ids, question_ids] = True
      return dense_y, y_mask
  
file_path: probability/spinoffs/inference_gym/inference_gym/targets/item_response_theory.py
imports: import functools
  import numpy
  import tensorflow.compat.v2
  import tensorflow_probability
  from tensorflow_probability.python.internal import prefer_static
  from inference_gym.internal import data
  from inference_gym.targets import bayesian_model
  from inference_gym.targets import model
  from inference_gym.targets.ground_truth import synthetic_item_response_theory
label_desc: Use image node_id 2 for calling the ItemResponseTheory obj's underlying member method code with example usage: obj._sparse_to_dense(student_ids, question_ids, correct) and returns: dense_y,  y_mask