code: def joint_pdf(
      kernel_values1: torch.Tensor,
      kernel_values2: torch.Tensor,
      epsilon: float = 1e-10,
  ) -> torch.Tensor:
      """Calculate the joint probability distribution function of the input tensors based on the number of histogram
      bins.
  
      Args:
          kernel_values1: shape [BxNxNUM_BINS].
          kernel_values2: shape [BxNxNUM_BINS].
          epsilon: scalar, for numerical stability.
  
      Returns:
          shape [BxNUM_BINSxNUM_BINS].
      """
      if not isinstance(kernel_values1, torch.Tensor):
          raise TypeError(
              f"Input kernel_values1 type is not a torch.Tensor. Got {type(kernel_values1)}"
          )
  
      if not isinstance(kernel_values2, torch.Tensor):
          raise TypeError(
              f"Input kernel_values2 type is not a torch.Tensor. Got {type(kernel_values2)}"
          )
  
      if not kernel_values1.dim() == 3:
          raise ValueError(
              f"Input kernel_values1 must be a of the shape BxN. Got {kernel_values1.shape}"
          )
  
      if not kernel_values2.dim() == 3:
          raise ValueError(
              f"Input kernel_values2 must be a of the shape BxN. Got {kernel_values2.shape}"
          )
  
      if kernel_values1.shape != kernel_values2.shape:
          raise ValueError(
              "Inputs kernel_values1 and kernel_values2 must have the same shape."
              f" Got {kernel_values1.shape} and {kernel_values2.shape}"
          )
  
      joint_kernel_values = torch.matmul(
          kernel_values1.transpose(1, 2), kernel_values2
      )
      normalization = (
          torch.sum(joint_kernel_values, dim=(1, 2)).view(-1, 1, 1)
          + epsilon
      )
      pdf = joint_kernel_values / normalization
  
      return pdf
  
imports: from typing import Optional, Tuple
  import torch
label_desc: Use image node_id 2 for calling a global function with example usage: joint_pdf(kernel_values1, kernel_values2, epsilon) and returns: pdf