docstr: Chooses the best arm from a set of availabe arms based on contextual features.
  GreedyActionSampler may be applied.
docstr_tok: ["Chooses","the","best","arm","from","a","set","of","availabe","arms","based","on","contextual","features",".","GreedyActionSampler","may","be","applied","."]
code: def act(
      self,
      obs: Any,
      possible_actions_mask: Optional[torch.Tensor] = None,
  ) -> rlt.ActorOutput:
      """
      Chooses the best arm from a set of availabe arms based on contextual features.
      GreedyActionSampler may be applied.
      """
      scorer_inputs = (obs,)
      if possible_actions_mask is not None:
          scorer_inputs += (possible_actions_mask,)
      model_output = self.scorer(*scorer_inputs)
      scores = model_output["ucb"]
      actor_output = self.sampler.sample_action(scores)
      return actor_output.cpu().detach()
  
imports: import random
  from dataclasses import replace
  from typing import Any, Optional, Tuple
  import reagent.core.types
  import torch
  from reagent.core.types import CBInput
  from reagent.gym.policies.policy import Policy
  from reagent.gym.policies.samplers.discrete_sampler import GreedyActionSampler
  from reagent.gym.types import Sampler, Scorer
  from reagent.models.linear_regression import LinearRegressionUCB
  from reagent.training.cb.base_trainer import BaseCBTrainerWithEval
  from reagent.training.cb.linucb_trainer import LinUCBTrainer
  from reagent.training.parameters import LinUCBTrainerParameters
label_desc: Use image node_id 2 for calling the Policy obj's underlying member method code with example usage: obj.act(obs, possible_actions_mask) and returns: actor_output