code: def sample(
      population: int,
      k: int,
      device: Optional[Union[torch.device, str]] = None,
  ) -> Tensor:
      if population <= k:
          return torch.arange(population, device=device)
      else:
          return torch.tensor(
              random.sample(range(population), k), device=device
          )
  
file_path: pytorch_geometric/torch_geometric/utils/_negative_sampling.py
imports: import random
  from typing import Optional, Tuple, Union
  import numpy
  import torch
  from torch import Tensor
  from torch_geometric.utils import coalesce, cumsum, degree, remove_self_loops
  from torch_geometric.utils.num_nodes import maybe_num_nodes
label_desc: Use image node_id 5 for calling a global function with example usage: sample(population, k, device) and returns: torch, torch