The H and W are height and width of the image NOT the rectangle. How can the corners be outside the image ?
Please read the doc of fasterrcnn
Implements Faster R-CNN.
    The input to the model is expected to be a list of tensors, each of shape [C, H, W], one for each
    image, and should be in 0-1 range. Different images can have different sizes.
    The behavior of the model changes depending if it is in training or evaluation mode.
    During training, the model expects both the input tensors, as well as a targets (list of dictionary),
    containing:
        - boxes (FloatTensor[N, 4]): the ground-truth boxes in [x1, y1, x2, y2] format, with values of x
          between 0 and W and values of y between 0 and H
        - labels (Int64Tensor[N]): the class label for each ground-truth box

In this example
x1: 100, y1: 100
x2: 400, y2: 300

h: 200, w: 300

surely height of image is greater than 300 and width greater than 400, otherwise how will the corners be outside.