class_docstr: Global buffer to avoid dynamic memory allocations.
  Caller should ensure that buffers of the same name
  are not used concurrently.
class_docstr_tok: ["Global","buffer","to","avoid","dynamic","memory","allocations",".","Caller","should","ensure","that","buffers","of","the","same","name","are","not","used","concurrently","."]
code: def get_tensor(self, tensor_shape, dtype, name):
      required_len = reduce(operator.mul, tensor_shape, 1)
      if (
          self.buffer.get((name, dtype), None) is None
          or self.buffer[(name, dtype)].numel() < required_len
      ):
          self.buffer[(name, dtype)] = torch.empty(
              required_len,
              dtype=dtype,
              device=torch.cuda.current_device(),
              requires_grad=False,
          )
  
      return self.buffer[(name, dtype)][0:required_len].view(
          *tensor_shape
      )
  
imports: import math
  import operator
  from functools import reduce
  import torch
  from megatron.core import parallel_state
  from megatron.core.dist_checkpointing.mapping import ShardedTensor
label_desc: Use image node_id 2 for calling the GlobalMemoryBuffer obj's underlying member method code with example usage: obj.get_tensor(tensor_shape, dtype, name) and returns: self