how do I map tensor using dictionary
im trying to map tensor using dictionary but envir_with_agent[1,2] return tensor(4) instead 4 and dictionary cannot map it correctly min code is below
 envir_with_agent = b.mountain.clone()
envir_with_agent[b.position_agent[0], b.position_agent[1]] = 4
print(envir_with_agent[1,2])
print(b.dict_map_display[envir_with_agent[1,2]])

dict
        self.dict_map_display={ 
                            1:'.',
                            2:'o',
                            3:'O',
                            4:'A',
                            8:'E', 
                            9:'X'}

error


KeyError                                  Traceback (most recent call
last)  in 
2 envir_with_agent[b.position_agent[0], b.position_agent[1]] = 4
3 print(envir_with_agent[1,2])
----&gt; 4 print(b.dict_map_display[envir_with_agent[1,2]])
KeyError: tensor(4)


You would want to first convert the scalar tensor to type int before using it as an index; like this:
envir_with_agent = b.mountain.clone()
envir_with_agent[int(b.position_agent[0]), int(b.position_agent[1])] = 4

