def loss(self, step_count: int, model: ActorCriticModel, batch: Dict[(str, Union[(torch.Tensor, Dict[(str, torch.Tensor)])])], memory: Memory, **kwargs) -> Tuple[(torch.FloatTensor, Dict[(str, float)], Memory, int)]:
    (rollout_len, nrollouts, _) = batch['poisoned_door_state'].shape
    observations = {'poisoned_door_state': batch['poisoned_door_state']}
    (ac_out, memory) = model.forward(observations=observations, memory=memory, prev_actions=None, masks=batch['masks'].view(rollout_len, nrollouts, (- 1)))
    (total_loss, losses_dict) = self.advisor_loss.loss(step_count=step_count, batch={'observations': {'expert_action': torch.cat((batch['expert_action'].view(rollout_len, nrollouts, 1), torch.ones(rollout_len, nrollouts, 1, dtype=torch.int64).to(batch['expert_action'].device)), dim=(- 1))}}, actor_critic_output=ac_out)
    info = {('offpolicy_' + key): val for (key, val) in losses_dict.items()}
    if (self.total_episodes_in_epoch is not None):
        if ('completed_episode_count' not in memory):
            memory['completed_episode_count'] = 0
        memory['completed_episode_count'] += (int(np.prod(batch['masks'].shape)) - batch['masks'].sum().item())
        info['epoch_progress'] = (memory['completed_episode_count'] / self.total_episodes_in_epoch)
    return (total_loss, info, memory, (rollout_len * nrollouts))
def loss(self, step_count: int, model: ActorCriticModel, batch: Dict[(str, Union[(torch.Tensor, Dict[(str, torch.Tensor)])])], memory: Memory, **kwargs) -> Tuple[(torch.FloatTensor, Dict[(str, float)], Memory, int)]:
    (rollout_len, nrollouts, _) = batch['poisoned_door_state'].shape
    observations = {'poisoned_door_state': batch['poisoned_door_state']}
    (ac_out, memory) = model.forward(observations=observations, memory=memory, prev_actions=None, masks=batch['masks'].view(rollout_len, nrollouts, (- 1)))
    (total_loss, losses_dict) = self.advisor_loss.loss(step_count=step_count, batch={'observations': {'expert_action': torch.cat((batch['expert_action'].view(rollout_len, nrollouts, 1), torch.ones(rollout_len, nrollouts, 1, dtype=torch.int64).to(batch['expert_action'].device)), dim=(- 1))}}, actor_critic_output=ac_out)
    info = {('offpolicy_' + key): val for (key, val) in losses_dict.items()}
    if (self.total_episodes_in_epoch is not None):
        if ('completed_episode_count' not in memory):
            memory['completed_episode_count'] = 0
        memory['completed_episode_count'] += (int(np.prod(batch['masks'].shape)) - batch['masks'].sum().item())
        info['epoch_progress'] = (memory['completed_episode_count'] / self.total_episodes_in_epoch)
    return (total_loss, info, memory, (rollout_len * nrollouts))