docstr: Used in Q-learning update.
  
  :param q_values: PyTorch tensor with shape (batch_size, action_dim). Each row
      contains the list of Q-values for each possible action in this state.
  
  :param q_values_target: PyTorch tensor with shape (batch_size, action_dim). Each row
      contains the list of Q-values from the target network
      for each possible action in this state.
  
  :param possible_actions_mask: PyTorch tensor with shape (batch_size, action_dim).
      possible_actions[i][j] = 1 iff the agent can take action j from
      state i.
  
  Returns a tensor of maximum Q-values for every state in the batch
      and also the index of the corresponding action (which is used in
      evaluation_data_page.py, in create_from_tensors_dqn()).
docstr_tok: ["Used","in","Q-learning","update",".",":","param","q_values",":","PyTorch","tensor","with","shape","(","batch_size",",","action_dim",")",".","Each","row","contains","the","list","of","Q-values","for","each","possible","action","in","this","state",".",":","param","q_values_target",":","PyTorch","tensor","with","shape","(","batch_size",",","action_dim",")",".","Each","row","contains","the","list","of","Q-values","from","the","target","network","for","each","possible","action","in","this","state",".",":","param","possible_actions_mask",":","PyTorch","tensor","with","shape","(","batch_size",",","action_dim",")",".","possible_actions","[","i","]","[","j","]","=","1","iff","the","agent","can","take","action","j","from","state","i",".","Returns","a","tensor","of","maximum","Q-values","for","every","state","in","the","batch","and","also","the","index","of","the","corresponding","action","(","which","is","used","in","evaluation_data_page.py",",","in","create_from_tensors_dqn","(",")",")","."]
code: def get_max_q_values_with_target(
      self, q_values, q_values_target, possible_actions_mask
  ):
      """
      Used in Q-learning update.
  
      :param q_values: PyTorch tensor with shape (batch_size, action_dim). Each row
          contains the list of Q-values for each possible action in this state.
  
      :param q_values_target: PyTorch tensor with shape (batch_size, action_dim). Each row
          contains the list of Q-values from the target network
          for each possible action in this state.
  
      :param possible_actions_mask: PyTorch tensor with shape (batch_size, action_dim).
          possible_actions[i][j] = 1 iff the agent can take action j from
          state i.
  
      Returns a tensor of maximum Q-values for every state in the batch
          and also the index of the corresponding action (which is used in
          evaluation_data_page.py, in create_from_tensors_dqn()).
  
      """
  
      # The parametric DQN can create flattened q values so we reshape here.
      q_values = q_values.reshape(possible_actions_mask.shape)
      q_values_target = q_values_target.reshape(
          possible_actions_mask.shape
      )
      # Set q-values of impossible actions to a very large negative number.
      inverse_pna = 1 - possible_actions_mask
      impossible_action_penalty = (
          self.ACTION_NOT_POSSIBLE_VAL * inverse_pna
      )
      q_values = q_values + impossible_action_penalty
      q_values_target = q_values_target + impossible_action_penalty
  
      if self.double_q_learning:
          # Use indices of the max q_values from the online network to select q-values
          # from the target network. This prevents overestimation of q-values.
          # The torch.gather function selects the entry from each row that corresponds
          # to the max_index in that row.
          max_q_values, max_indicies = torch.max(
              q_values, dim=1, keepdim=True
          )
          max_q_values_target = torch.gather(
              q_values_target, 1, max_indicies
          )
      else:
          max_q_values_target, max_indicies = torch.max(
              q_values_target, dim=1, keepdim=True
          )
  
      return max_q_values_target, max_indicies
  
imports: import logging
  from abc import abstractmethod
  from typing import Dict, List, Optional
  import reagent.core.types
  import torch
  import torch.nn.functional
  from reagent.core.parameters import EvaluationParameters, RLParameters
  from reagent.core.torch_utils import masked_softmax
  from reagent.evaluation.evaluation_data_page import EvaluationDataPage
  from reagent.evaluation.evaluator import Evaluator
  from reagent.optimizer import Optimizer__Union
  from reagent.training.reagent_lightning_module import ReAgentLightningModule
  from reagent.training.rl_trainer_pytorch import RLTrainerMixin
label_desc: Use image node_id 2 for calling the DQNTrainerMixin obj's underlying member method code with example usage: obj.get_max_q_values_with_target(q_values, q_values_target, possible_actions_mask) and returns: max_q_values_target,  max_indicies