Information about variables that connected to graph

Hello! Does anybody know how can I get information about variable’s connection to graph? For example, I have a tensor A with shape [3, 5, 10] and required_grad=True, Let’s say I just want to create new tensor in for loop that will be connected to the same graph. And for example, if I will create just an empty tensor B like torch.empty(3, 5, 10) and then insert rows from A to B like B[I] = A[I] in for loop, B will not be connected to the graph of A, but if I will use B = torch.tensor() and then[I], A)) in for loop - graph will be the same. Here is a question: how can I get information about torch operations that will use the same graph with new variable.