import torch
import torch.nn as nn

N, C, H, W = 32, 64, 56, 56

class CharbonnierLoss(nn.Module):
    def __init__(self, reduction='mean', eps=1e-3):
        super().__init__()
        self.reduction = reduction
        self.eps = eps

    def forward(self, input, target):
        diff = input - target
        loss = torch.sqrt(diff * diff + self.eps * self.eps)

        if self.reduction == 'mean':
            return loss.mean()
        elif self.reduction == 'sum':
            return loss.sum()
        else:
            return loss

class Model(nn.Module):
    def __init__(self, reduction='mean', eps=1e-3):
        super().__init__()
        self.op = CharbonnierLoss(reduction, eps)

    def forward(self, input, target):
        return self.op(input, target)

def get_inputs():
    input = torch.randn(N, C, H, W, dtype=torch.float32)
    target = torch.randn(N, C, H, W, dtype=torch.float32)
    return [input, target]

def get_init_inputs():
    return ['mean', 1e-3]