code: def shoot_infs(inp_tensor):
      """Replaces inf by maximum of tensor"""
      mask_inf = torch.isinf(inp_tensor)
      ind_inf = torch.nonzero(mask_inf, as_tuple=False)
      if len(ind_inf) > 0:
          for ind in ind_inf:
              if len(ind) == 2:
                  inp_tensor[ind[0], ind[1]] = 0
              elif len(ind) == 1:
                  inp_tensor[ind[0]] = 0
          m = torch.max(inp_tensor)
          for ind in ind_inf:
              if len(ind) == 2:
                  inp_tensor[ind[0], ind[1]] = m
              elif len(ind) == 1:
                  inp_tensor[ind[0]] = m
      return inp_tensor
  
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 2 for calling a global function with example usage: shoot_infs(inp_tensor) and returns: inp_tensor