Try to initialize Metric as a module via:
class Metric(nn.Module):
    def __init__(self):
        super(Metric, self).__init__()
        latent_dim = None
        embed = None
        kernel = None

and it should work.