code: def tv_loss(input):
      """L2 total variation loss, as in Mahendran et al."""
      input = F.pad(input, (0, 1, 0, 1), "replicate")
      x_diff = input[..., :-1, 1:] - input[..., :-1, :-1]
      y_diff = input[..., 1:, :-1] - input[..., :-1, :-1]
      return (x_diff**2 + y_diff**2).mean([1, 2, 3])
  
file_path: PaddleHub/modules/image/text_to_image/disco_diffusion_cnclip_vitb16/reverse_diffusion/model/losses.py
imports: import numpy
  import paddle
  import paddle.nn.functional
label_desc: Use image node_id 5 for calling a global function with example usage: tv_loss(input) and returns: unknown