class_docstr: Simulate click data with position bias model. There are other models available in
  `ULTRA <https://github.com/ULTR-Community/ULTRA.git>`_ like the cascading model.
  
  References
  ----------
  Unbiased LambdaMART: An Unbiased Pairwise Learning-to-Rank Algorithm
class_docstr_tok: ["Simulate","click","data","with","position","bias","model",".","There","are","other","models","available","in","`","ULTRA","<","https",":","\/\/github.com\/ULTR-Community\/ULTRA.git",">","`","_","like","the","cascading","model",".","References","--","--","--","--","--","Unbiased","LambdaMART",":","An","Unbiased","Pairwise","Learning-to-Rank","Algorithm"]
docstr: Sample clicks for one query based on input relevance degree and position.
  
  Parameters
  ----------
  
  labels :
      relevance_degree
docstr_tok: ["Sample","clicks","for","one","query","based","on","input","relevance","degree","and","position",".","Parameters","--","--","--","--","--","labels",":","relevance_degree"]
code: def sample_clicks_for_query(
      self,
      labels: npt.NDArray[np.int32],
      position: npt.NDArray[np.int64],
  ) -> npt.NDArray[np.int32]:
      """Sample clicks for one query based on input relevance degree and position.
  
      Parameters
      ----------
  
      labels :
          relevance_degree
  
      """
      labels = np.array(labels, copy=True)
  
      click_prob = np.zeros(labels.shape)
      # minimum
      labels[labels < 0] = 0
      # maximum
      labels[labels >= len(self.click_prob)] = -1
      click_prob = self.click_prob[labels]
  
      exam_prob = np.zeros(labels.shape)
      assert position.size == labels.size
      ranks = np.array(position, copy=True)
      # maximum
      ranks[ranks >= self.exam_prob.size] = -1
      exam_prob = self.exam_prob[ranks]
  
      rng = np.random.default_rng(1994)
      prob = rng.random(size=labels.shape[0], dtype=np.float32)
  
      clicks: npt.NDArray[np.int32] = np.zeros(
          labels.shape, dtype=np.int32
      )
      clicks[prob < exam_prob * click_prob] = 1
      return clicks
  
imports: import os
  import zipfile
  from dataclasses import dataclass
  from typing import TYPE_CHECKING, Any, Callable, Dict, Generator, NamedTuple, Optional, Tuple, Type, Union
  from urllib import request
  import numpy
  import pytest
  from numpy import typing
  from numpy.random import Generator
  from scipy import sparse
  import xgboost
  from xgboost.data import pandas_pyarrow_mapper
label_desc: Use image node_id 2 for calling the PBM obj's underlying member method code with example usage: obj.sample_clicks_for_query(labels, position) and returns: clicks