Calculate covariance matrix between two sample of the same and different classes

Hello
Suppose I have a batch with a size of 16 that contains some triplet samples (A, P, N). Where samples A and P are from the same class and the other sample N is from a different class. During the training process, I would like to calculate the covariance matrices Cov(A, P) and Cov(A, N). In each iteration the selection batches are random for example with labels 0 to 9 my first batch would like as:
[[1, 1, 2],
[1, 1, 0],
[2, 2, 1],
[9, 9, 5],
[1, 1, 8],
[2, 2, 4],
[6, 6, 9],
[3, 3, 0],
[3, 3, 1],
[3, 3, 5],
[1, 1, 8],
[6, 6, 7],
[3, 3, 4],
[5, 5, 1],
[5, 5, 2],
[5, 5, 8]]

Thanks