Change:
else: sz = exp_max + 6 sz = max(min_sz, sz) <del> format = '{:' + str(sz) + '.4f}' </del> <ins> format = '{{:{}.{}f}}'.format(sz, prec) </ins> return format, scale, sz def _tensor_str(self): <ins> n = PRINT_OPTS.edgeitems has_hdots = self.size()[-1] > 2*n has_vdots = self.size()[-2] > 2*n print_full_mat = not has_hdots and not has_vdots formatter = _number_format(self, min_sz=3 if not print_full_mat else 0) print_dots = self.numel() >= PRINT_OPTS.threshold dim_sz = max(2, max(len(str(x)) for x in self.size())) dim_fmt = "{:^" + str(dim_sz) + "}" dot_fmt = u"{:^" + str(dim_sz+1) + "}" </ins> counter_dim = self.ndimension() - 2 counter = torch.LongStorage(counter_dim).fill_(0) <del> counter[0] = -1 </del> <ins> counter[counter.size()-1] = -1 </ins> finished = False strt = '' while True: <del> for i in _range(counter_dim): </del> <ins> nrestarted = [False for i in counter] nskipped = [False for i in counter] for i in _range(counter_dim - 1, -1, -1): </ins> counter[i] += 1 <ins> if print_dots and counter[i] == n and self.size(i) > 2*n: counter[i] = self.size(i) - n nskipped[i] = True </ins> if counter[i] == self.size(i): <del> if i == counter_dim-1: </del> <ins> if i == 0: </ins> finished = True counter[i] = 0 <ins> nrestarted[i] = True </ins> else: break if finished: break <ins> elif print_dots: if any(nskipped): for hdot in nskipped: strt += dot_fmt.format('...') if hdot  else dot_fmt.format('') strt += 'n' if any(nrestarted): strt += ' ' for vdot in nrestarted: strt += dot_fmt.format(u'u22EE' if vdot else '') strt += 'n' </ins> if strt != '': <del> strt += 'n' strt += '({},.,.) = n'.format(','.join(str(i) for i in counter)) submatrix = reduce(lambda t,i: t.select(0, i), counter, self) strt += _matrix_str(submatrix, ' ') </del> <ins> strt += 'n' strt += '({},.,.) = n'.format( ','.join(dim_fmt.format(i) for i in counter)) submatrix = reduce(lambda t, i: t.select(0, i), counter, self) strt += _matrix_str(submatrix, ' ', formatter, print_dots) </ins> return strt <del> def _matrix_str(self, indent=''): fmt, scale, sz = _number_format(self) nColumnPerLine = int(math.floor((80-len(indent))/(sz+1))) </del> <ins> def __repr_row(row, indent, fmt, scale, sz, truncate=None): if truncate is not None: dotfmt = " {:^5} " return (indent + ' '.join(fmt.format(val/scale) for val in row[:truncate]) + dotfmt.format('...') + ' '.join(fmt.format(val/scale) for val in row[-truncate:]) + 'n') else: return indent + ' '.join(fmt.format(val/scale) for val in row) + 'n' def _matrix_str(self, indent='', formatter=None, force_truncate=False): n = PRINT_OPTS.edgeitems has_hdots = self.size(1) > 2*n has_vdots = self.size(0) > 2*n print_full_mat = not has_hdots and not has_vdots if formatter is None: fmt, scale, sz = _number_format(self, min_sz=5 if not print_full_mat else 0) else: fmt, scale, sz = formatter nColumnPerLine = int(math.floor((PRINT_OPTS.linewidth-len(indent))/(sz+1))) </ins> strt = '' firstColumn = 0 <del> while firstColumn < self.size(1): lastColumn = min(firstColumn + nColumnPerLine - 1, self.size(1)-1) if nColumnPerLine < self.size(1): strt += 'n' if firstColumn != 1 else '' strt += 'Columns {} to {} n{}'.format(firstColumn, lastColumn, indent) </del> <ins> if not force_truncate and  (self.numel() < PRINT_OPTS.threshold or print_full_mat): while firstColumn < self.size(1): lastColumn = min(firstColumn + nColumnPerLine - 1, self.size(1)-1) if nColumnPerLine < self.size(1): strt += 'n' if firstColumn != 1 else '' strt += 'Columns {} to {} n{}'.format( firstColumn, lastColumn, indent) if scale != 1: strt += SCALE_FORMAT.format(scale) for l in _range(self.size(0)): strt += indent + (' ' if scale != 1 else '') row_slice = self[l, firstColumn:lastColumn+1] strt += ' '.join(fmt.format(val/scale) for val in row_slice) strt += 'n' firstColumn = lastColumn + 1 else: </ins> if scale != 1: strt += SCALE_FORMAT.format(scale) <del> for l in _range(self.size(0)): strt += indent + (' ' if scale != 1 else '') row_slice = self[l, firstColumn:lastColumn+1] strt += ' '.join(fmt.format(val/scale) for val in row_slice) + 'n' firstColumn = lastColumn + 1 </del> <ins> if has_vdots and has_hdots: vdotfmt = "{:^" + str((sz+1)*n-1) + "}" ddotfmt = u"{:^5}" for row in self[:n]: strt += __repr_row(row, indent, fmt, scale, sz, n) strt += indent + ' '.join([vdotfmt.format('...'), ddotfmt.format(u'u22F1'), vdotfmt.format('...')]) + "n" for row in self[-n:]: strt += __repr_row(row, indent, fmt, scale, sz, n) elif not has_vdots and has_hdots: for row in self: strt += __repr_row(row, indent, fmt, scale, sz, n) elif has_vdots and not has_hdots: vdotfmt = u"{:^" +  str(len(__repr_row(self[0], '', fmt, scale, sz))) +  "}n" for row in self[:n]: strt += __repr_row(row, indent, fmt, scale, sz) strt += vdotfmt.format(u'u22EE') for row in self[-n:]: strt += __repr_row(row, indent, fmt, scale, sz) else: for row in self: strt += __repr_row(row, indent, fmt, scale, sz) </ins> return strt def _vector_str(self): <del> fmt, scale, _ = _number_format(self) </del> <ins> fmt, scale, sz = _number_format(self) </ins> strt = '' ident = '' <ins> n = PRINT_OPTS.edgeitems dotfmt = u"{:^" + str(sz) + "}n" </ins> if scale != 1: strt += SCALE_FORMAT.format(scale) ident = ' ' <del> return strt + 'n'.join(ident + fmt.format(val/scale) for val in self) + 'n' </del> <ins> if self.numel() < PRINT_OPTS.threshold: return (strt + 'n'.join(ident + fmt.format(val/scale) for val in self) + 'n') else: return (strt + 'n'.join(ident + fmt.format(val/scale) for val in self[:n]) + 'n' + (ident + dotfmt.format(u"u22EE")) + 'n'.join(ident + fmt.format(val/scale) for val in self[-n:]) + 'n') </ins> def _str(self):

Discussion:
It seems that the following link that can be reached from here (check the screenshot) is broken: Page: Broken link: Screenshot: ! cc
this should be transferred to , but I don't have permissions to do that. Fix is available at pytorch/hub.