code: def calc_sample_norms_one_layer(param: torch.Tensor) -> torch.Tensor:
      r"""
      Calculates the norm of the given tensor (a single parameter) for each sample.
  
      This function calculates the overall norm of the given tensor for each sample,
      assuming each batch's dim is zero.
  
      It is equivalent to:
      `calc_sample_norms(named_params=((None, param),))[0]`
  
      Args:
          param: A tensor of shape ``[B, ...]`` where ``B``
              is the size of the batch and is the 0th dimension.
  
      Returns:
          A tensor of norms
  
      Example:
          >>> t1 = torch.rand((2, 5))
          >>> norms = calc_sample_norms_one_layer(t1)
          >>> norms, norms.shape
          (tensor([...]), torch.Size([2]))
      """
      norms = param.view(len(param), -1).norm(2, dim=-1)
      return norms
  
file_path: opacus/opacus/utils/tensor_utils.py
imports: import math
  from typing import Iterator, List, Tuple, Union
  import numpy
  import torch
  import torch.nn.functional
label_desc: Use image node_id 2 for calling a global function with example usage: calc_sample_norms_one_layer(param) and returns: norms