class_docstr: Asymmetric metric learning (AML) Criterion used in
  "New Insights on Reducing Abrupt Representation
  Change in Online Continual Learning"
  by Lucas Caccia et. al.
  https://openreview.net/forum?id=N8MaByOzUfb
docstr: Method able to sample positive and negative examples with respect the input minibatch from input and buffer minibatches.
  :param x_in: Input of new minibatch.
  :param y_in: Output of new minibatch.
  :param t_in: Task ids of new minibatch.
  :param x_memory: Input of memory.
  :param y_memory: Output of minibatch.
  :param t_memory: Task ids of minibatch.
  :return: Tuple of positive and negative input and output examples and a mask for identify invalid values.
docstr_tok: ["Method","able","to","sample","positive","and","negative","examples","with","respect","the","input","minibatch","from","input","and","buffer","minibatches",".",":","param","x_in",":","Input","of","new","minibatch",".",":","param","y_in",":","Output","of","new","minibatch",".",":","param","t_in",":","Task","ids","of","new","minibatch",".",":","param","x_memory",":","Input","of","memory",".",":","param","y_memory",":","Output","of","minibatch",".",":","param","t_memory",":","Task","ids","of","minibatch",".",":","return",":","Tuple","of","positive","and","negative","input","and","output","examples","and","a","mask","for","identify","invalid","values","."]
code: def __sample_pos_neg(
      self,
      y_in: torch.Tensor,
      t_in: torch.Tensor,
      x_memory: torch.Tensor,
      y_memory: torch.Tensor,
      t_memory: torch.Tensor,
  ) -> tuple:
      """
      Method able to sample positive and negative examples with respect the input minibatch from input and buffer minibatches.
      :param x_in: Input of new minibatch.
      :param y_in: Output of new minibatch.
      :param t_in: Task ids of new minibatch.
      :param x_memory: Input of memory.
      :param y_memory: Output of minibatch.
      :param t_memory: Task ids of minibatch.
      :return: Tuple of positive and negative input and output examples and a mask for identify invalid values.
      """
      valid_pos = y_in.reshape(1, -1) == y_memory.reshape(-1, 1)
      if self.same_task_neg:
          same_task = t_in.view(1, -1) == t_memory.view(-1, 1)
          valid_neg = ~valid_pos & same_task
      else:
          valid_neg = ~valid_pos
  
      pos_idx = torch.multinomial(valid_pos.float().T, 1).squeeze(1)
      neg_idx = torch.multinomial(valid_neg.float().T, 1).squeeze(1)
  
      pos_x = x_memory[pos_idx]
      pos_y = y_memory[pos_idx]
      neg_x = x_memory[neg_idx]
      neg_y = y_memory[neg_idx]
  
      return pos_x, pos_y, neg_x, neg_y
  
imports: import copy
  from collections import defaultdict
  from typing import List
  import torch
  import torch.nn.functional
  from avalanche.models import MultiTaskModule, avalanche_forward
label_desc: Use image node_id 2 for calling the AMLCriterion obj's underlying member method code with example usage: obj.__sample_pos_neg(y_in, t_in, x_memory, y_memory, t_memory) and returns: pos_x,  pos_y,  neg_x,  neg_y