code: def ipot(
      C: Tensor,
      x_len: int,
      x_pad: Tensor,
      y_len: int,
      y_pad: Tensor,
      joint_pad: Tensor,
      beta: float,
      iteration: int,
      k: int,
  ) -> Tensor:
      """[B, M, N], [B], [B, M], [B], [B, N], [B, M, N]"""
      b, m, n = C.size()
      sigma = torch.ones(
          b, m, dtype=C.dtype, device=C.device
      ) / x_len.unsqueeze(1)
      T = torch.ones(b, n, m, dtype=C.dtype, device=C.device)
      A = torch.exp(-C.transpose(1, 2) / beta)
  
      # mask padded positions
      sigma.masked_fill_(x_pad, 0)
      joint_pad = joint_pad.transpose(1, 2)
      T.masked_fill_(joint_pad, 0)
      A.masked_fill_(joint_pad, 0)
  
      # broadcastable lengths
      x_len = x_len.unsqueeze(1).unsqueeze(2)
      y_len = y_len.unsqueeze(1).unsqueeze(2)
  
      # mask to zero out padding in delta and sigma
      x_mask = (x_pad.to(C.dtype) * 1e4).unsqueeze(1)
      y_mask = (y_pad.to(C.dtype) * 1e4).unsqueeze(1)
  
      for _ in range(iteration):
          Q = A * T  # bs * n * m
          sigma = sigma.view(b, m, 1)
          for _ in range(k):
              delta = 1 / (
                  y_len * Q.matmul(sigma).view(b, 1, n) + y_mask
              )
              sigma = 1 / (x_len * delta.matmul(Q) + x_mask)
          T = delta.view(b, n, 1) * Q * sigma
      T.masked_fill_(joint_pad, 0)
      return T
  
imports: import torch
  from torch import Tensor
  from torch.nn import functional
label_desc: Use image node_id 3 for calling a global function with example usage: ipot(C, x_len, x_pad, y_len, y_pad, joint_pad, beta, iteration, k) and returns: T