(n_actions, legal_actions_lists, device, dtype=torch.uint8)
return mask
Args:
        legal_actions_lists (list): List of lists. Each of the 2nd level lists contains legal actions as integers,
                                    where 0 is always FOLD, 1 is CHECK/CALL. 2 is BET/RAISE for continuous
                                    PokerEnvs, and for DiscretePokerEnv subclasses, numbers greater than 1 are all
                                    the raise sizes.

        device (torch.device):      device the mask shall be put on

        dtype:                      dtype the mask shall have

    Returns:
        torch.Tensor:               a many-hot representation of the list of legal actions.
def batch_get_legal_action_mask_torch(n_actions, legal_actions_lists, device, dtype=torch.uint8):
    """

    Args:
        legal_actions_lists (list): List of lists. Each of the 2nd level lists contains legal actions as integers,
                                    where 0 is always FOLD, 1 is CHECK/CALL. 2 is BET/RAISE for continuous
                                    PokerEnvs, and for DiscretePokerEnv subclasses, numbers greater than 1 are all
                                    the raise sizes.

        device (torch.device):      device the mask shall be put on

        dtype:                      dtype the mask shall have

    Returns:
        torch.Tensor:               a many-hot representation of the list of legal actions.

    """
    assert isinstance(legal_actions_lists[0], list), "need list of lists of legal actions (as ints)!"

    mask = torch.zeros((len(legal_actions_lists), n_actions,), device=device, dtype=dtype)
    for i, legal_action_list in enumerate(legal_actions_lists):
        mask[i, torch.LongTensor(legal_action_list, device=device)] = 1
    return mask
def batch_get_legal_action_mask_torch ( n_actions , legal_actions_lists , device , dtype = torch . uint8 ) : assert isinstance ( legal_actions_lists [ 0 ] , list ) , "need list of lists of legal actions (as ints)!" mask = torch . zeros ( ( len ( legal_actions_lists ) , n_actions , ) , device = device , dtype = dtype ) for i , legal_action_list in enumerate ( legal_actions_lists ) : mask [ i , torch . LongTensor ( legal_action_list , device = device ) ] = 1 return mask