code: def get_actual_memory_allocated(n: int, device: torch.device) -> int:
      """
      Returns the CUDA memory allocated for a torch.int8 tensor of size n.
  
      Args:
          n: size of the tensor to get allocated memory for
          device: torch.device to allocate tensor on
  
      Returns:
          Number of bytes of CUDA memory allocated for a torch.int8 tensor of size n.
  
      Notes: Should only be called on CUDA devices. Resets CUDA memory statistics.
      """
      assert device.type == "cuda"
      prev_memory_allocated = torch.cuda.memory_allocated(device)
      tensor = get_n_byte_tensor(n, device=device)
      memory_allocated = torch.cuda.memory_allocated(device)
      del tensor
      torch.cuda.reset_peak_memory_stats(device)
      assert prev_memory_allocated == torch.cuda.memory_allocated(
          device
      )
      return memory_allocated - prev_memory_allocated
  
imports: from typing import Optional
  import pytest
  import torch
label_desc: Use image node_id 2 for calling a global function with example usage: get_actual_memory_allocated(n, device) and returns: unknown