code: def transport_daily(
      all_preds,
      label,
      choice,
      prob,
      hist_loss,
      count,
      transport_method,
      alpha,
      training=False,
  ):
      """
      daily transport
  
      Args:
          all_preds (torch.Tensor): predictions from all predictors, [sample x states]
          label (torch.Tensor): label, [sample]
          choice (torch.Tensor): gumbel softmax choice, [days x states]
          prob (torch.Tensor): router predicted probility, [days x states]
          hist_loss (torch.Tensor): history loss matrix, [days x states]
          count (list): sample counts for each day, [days]
          transport_method (str): transportation method
          alpha (float): fusion parameter for calculating transport loss matrix
          training (bool): indicate training or inference
      """
      assert len(prob) == len(count)
      assert len(all_preds) == sum(count)
      assert transport_method in ["oracle", "router"]
  
      all_loss = []  # loss of all predictions
      start = 0
      for i, cnt in enumerate(count):
          slc = slice(start, start + cnt)  # samples from the i-th day
          start += cnt
          tloss = loss_fn(
              all_preds[slc], label[slc]
          )  # loss of the i-th day
          all_loss.append(tloss)
      all_loss = torch.stack(all_loss, dim=0)  # [days x states]
  
      L = minmax_norm(all_loss.detach())
      Lh = L * alpha + minmax_norm(hist_loss) * (
          1 - alpha
      )  # add hist loss for transport
      Lh = minmax_norm(Lh)
      P = sinkhorn(-Lh)
      del Lh
  
      pred = []
      start = 0
      for i, cnt in enumerate(count):
          slc = slice(start, start + cnt)  # samples from the i-th day
          start += cnt
          if transport_method == "router":
              if training:
                  tpred = all_preds[slc] @ choice[i]  # gumbel softmax
              else:
                  tpred = all_preds[slc][
                      :, prob[i].argmax(dim=-1)
                  ]  # argmax
          else:
              tpred = all_preds[slc] @ P[i]
          pred.append(tpred)
      pred = torch.cat(pred, dim=0)  # [samples]
  
      if transport_method == "router":
          loss = loss_fn(pred, label)
      else:
          loss = (all_loss * P).sum(dim=1).mean()
  
      return loss, pred, L, P
  
imports: import io
  import os
  import copy
  import math
  import json
  import numpy
  import pandas
  import matplotlib.pyplot
  import torch
  import torch.nn
  import torch.optim
  import torch.nn.functional
  from tqdm import tqdm
  from qlib.constant import EPS
  from qlib.log import get_module_logger
  from qlib.model.base import Model
  from qlib.contrib.data.dataset import MTSDatasetH
label_desc: Use image node_id 7 for calling a global function with example usage: transport_daily(all_preds, label, choice, prob, hist_loss, count, transport_method, alpha, training) and returns: loss,  pred,  L,  P