Thank you, but boxes.size(0) and boxes.size()[0] doesn’t work.
I met the same error using boxes.size(0) and boxes.size()[0]:
Arguments for call are not valid.
The following operator variants are available:

  aten::size.int(Tensor self, int dim) -> (int):
  Expected a value of type 'Tensor' for argument 'self' but instead found type 'Optional[Tensor]'.

  aten::size(Tensor self) -> (int[]):
  Expected a value of type 'Tensor' for argument 'self' but instead found type 'Optional[Tensor]'.

The original call is:
at ocr.py:80:23
        img_tensor = resize_img(img_tensor)
        # self.show(img_tensor)

        img_tensor_ = (img_tensor - 0.5) / 0.5
        img_tensor_ = img_tensor_.permute(2,0,1).unsqueeze(0) # --> n x c x h x w
        boxes = self.east(img_tensor_)
        # self.show(img_tensor,boxes)
        new_boxes = []
        pass_list:List[int] = []
        for i in range(boxes.size(0)):
                       ~~~~~~~~~~ <--- HERE

And my code works well with environment variable  PYTORCH_JIT=0.
What’s the difference between boxes.size()/boxes.shape in python and torchscript?