class_docstr: A recommendation environment which generates items with visible features
  randomly (parametric actions).
  The environment can be configured to be multi-user, i.e. different models
  will be learned independently for each user, by setting num_users_in_db
  parameter.
  To enable slate recommendation, the `slate_size` config parameter can be
  set as > 1.
class_docstr_tok: ["A","recommendation","environment","which","generates","items","with","visible","features","randomly","(","parametric","actions",")",".","The","environment","can","be","configured","to","be","multi-user",",","i.e",".","different","models","will","be","learned","independently","for","each","user",",","by","setting","num_users_in_db","parameter",".","To","enable","slate","recommendation",",","the","`","slate_size","`","config","parameter","can","be","set","as",">","1","."]
docstr: Initializes a ParametricRecSys instance.
  
  Args:
      embedding_size: Embedding size for both users and docs.
          Each value in the user/doc embeddings can have values between
          -1.0 and 1.0.
      num_docs_to_select_from: The number of documents to present to the
          agent each timestep. The agent will then have to pick a slate
          out of these.
      slate_size: The size of the slate to recommend to the user at each
          timestep.
      num_docs_in_db: The total number of documents in the DB. Set this
          to None, in case you would like to resample docs from an
          infinite pool.
      num_users_in_db: The total number of users in the DB. Set this to
          None, in case you would like to resample users from an infinite
          pool.
      user_time_budget: The total time budget a user has throughout an
          episode. Once this time budget is used up (through engagements
          with clicked/selected documents), the episode ends.
docstr_tok: ["Initializes","a","ParametricRecSys","instance",".","Args",":","embedding_size",":","Embedding","size","for","both","users","and","docs",".","Each","value","in","the","user\/doc","embeddings","can","have","values","between","-1.0","and","1.0.","num_docs_to_select_from",":","The","number","of","documents","to","present","to","the","agent","each","timestep",".","The","agent","will","then","have","to","pick","a","slate","out","of","these",".","slate_size",":","The","size","of","the","slate","to","recommend","to","the","user","at","each","timestep",".","num_docs_in_db",":","The","total","number","of","documents","in","the","DB",".","Set","this","to","None",",","in","case","you","would","like","to","resample","docs","from","an","infinite","pool",".","num_users_in_db",":","The","total","number","of","users","in","the","DB",".","Set","this","to","None",",","in","case","you","would","like","to","resample","users","from","an","infinite","pool",".","user_time_budget",":","The","total","time","budget","a","user","has","throughout","an","episode",".","Once","this","time","budget","is","used","up","(","through","engagements","with","clicked\/selected","documents",")",",","the","episode","ends","."]
code: def __init__(
      self,
      embedding_size: int = 20,
      num_docs_to_select_from: int = 10,
      slate_size: int = 1,
      num_docs_in_db: Optional[int] = None,
      num_users_in_db: Optional[int] = None,
      user_time_budget: float = 60.0,
  ):
      """Initializes a ParametricRecSys instance.
  
      Args:
          embedding_size: Embedding size for both users and docs.
              Each value in the user/doc embeddings can have values between
              -1.0 and 1.0.
          num_docs_to_select_from: The number of documents to present to the
              agent each timestep. The agent will then have to pick a slate
              out of these.
          slate_size: The size of the slate to recommend to the user at each
              timestep.
          num_docs_in_db: The total number of documents in the DB. Set this
              to None, in case you would like to resample docs from an
              infinite pool.
          num_users_in_db: The total number of users in the DB. Set this to
              None, in case you would like to resample users from an infinite
              pool.
          user_time_budget: The total time budget a user has throughout an
              episode. Once this time budget is used up (through engagements
              with clicked/selected documents), the episode ends.
      """
      self.embedding_size = embedding_size
      self.num_docs_to_select_from = num_docs_to_select_from
      self.slate_size = slate_size
  
      self.num_docs_in_db = num_docs_in_db
      self.docs_db = None
      self.num_users_in_db = num_users_in_db
      self.users_db = None
      self.current_user = None
  
      self.user_time_budget = user_time_budget
      self.current_user_budget = user_time_budget
  
      self.observation_space = gym.spaces.Dict(
          {
              # The D docs our agent sees at each timestep.
              # It has to select a k-slate out of these.
              "doc": gym.spaces.Dict(
                  {
                      str(i): gym.spaces.Box(
                          -1.0,
                          1.0,
                          shape=(self.embedding_size,),
                          dtype=np.float32,
                      )
                      for i in range(self.num_docs_to_select_from)
                  }
              ),
              # The user engaging in this timestep/episode.
              "user": gym.spaces.Box(
                  -1.0,
                  1.0,
                  shape=(self.embedding_size,),
                  dtype=np.float32,
              ),
              # For each item in the previous slate, was it clicked?
              # If yes, how long was it being engaged with (e.g. watched)?
              "response": gym.spaces.Tuple(
                  [
                      gym.spaces.Dict(
                          {
                              # Clicked or not?
                              "click": gym.spaces.Discrete(2),
                              # Engagement time (how many minutes watched?).
                              "engagement": gym.spaces.Box(
                                  0.0, 100.0, shape=(), dtype=np.float32
                              ),
                          }
                      )
                      for _ in range(self.slate_size)
                  ]
              ),
          }
      )
      # Our action space is
      self.action_space = gym.spaces.MultiDiscrete(
          [self.num_docs_to_select_from for _ in range(self.slate_size)]
      )
  
file_path: ray/python/ray/rllib/examples/env/bandit_envs_recommender_system.py
imports: import gymnasium
  import numpy
  from typing import Optional
  from ray.rllib.utils.numpy import softmax
label_desc: Use image node_id 1 to create a new ParametricRecSys object from inherited base classes: gym with example: obj = ParametricRecSys(embedding_size, num_docs_to_select_from, slate_size, num_docs_in_db, num_users_in_db, user_time_budget)