code: def hamming_dist(x1: Tensor, x2: Tensor, x1_eq_x2: bool) -> Tensor:
      res = x1.size(-2) - (x1.unsqueeze(-3) * x2.unsqueeze(-4)).sum(
          dim=(-1, -2)
      )
      if x1_eq_x2 and not x1.requires_grad and not x2.requires_grad:
          res.diagonal(dim1=-2, dim2=-1).fill_(0)
      # Zero out negative values
      return res.clamp_min_(0)
  
imports: from typing import Optional
  import torch
  from torch import nn, Tensor
  from gpytorch.constraints.constraints import Interval, Positive
  from gpytorch.kernels.kernel import Kernel
  from gpytorch.priors.prior import Prior
label_desc: Use image node_id 1 for calling a global function with example usage: hamming_dist(x1, x2, x1_eq_x2) and returns: res