Getting indices of values in high dimension matrix
I have  tensorA of size 10x4x9x2, the other tensorB is of size 10x5x2 that contains values from tensorA. Now, how can i find the index of each element in tensorB in tensorA.
Example:
First 2 elements of  TensorA:
         [[[[ 4.,  1.],
          [ 1.,  2.],
          [ 2.,  5.],
          [ 5.,  3.],
          [ 3., 11.],
          [11., 10.],
          [10., -1.],
          [-1., -1.],
          [-1., -1.]],

         [[12., 13.],
          [13.,  9.],
          [ 9.,  7.],
          [ 7.,  5.],
          [ 5.,  3.],
          [ 3.,  4.],
          [ 4.,  1.],
          [ 1.,  0.],
          [ 0., -1.]],
          ...... so on

Fist 2 elements of TensorB:
   [[[ 2.,  5.],
     [ 5.,  7.],
     [ 7.,  9.],
     [ 9., 10.],
     [10., 12.]],
    
     [[ 0.,  1.],
     [ 1.,  2.],
     [ 2.,  5.],
     [ 5., -1.],
     [-1., -1.]],

Now in tensorB the first element is [2,5] included in the first 5x2 matrix (dimension 0).
so the element should be matched against dimension 0 in  tensorA. And the output should be index
0,0,2 since it is the 3rd element.

You can compare the rows that are equal, sum along the last axis, and check that sum against the size of the searched tensor. Then the nonzero function will get you the indices you're looking for.
Since for the example tensors you have given, TensorB[0, 0] is [2., 5.], that looks like:
((TensorA == TensorB[0, 0]).sum(dim=3) == 2).nonzero()

This will return a tensor of [[0, 0, 2]] if that is the only matching row. If you don't want to hard-code 2 (the size of the searched tensor), you can use:
((TensorA == TensorB[0, 0]).sum(dim=3) == TensorB[0, 0].size()[0]).nonzero()

