def get_pytorch_link(ft)->str:
    "Returns link to pytorch docs of `ft`."
    name = ft.__name__
    ext = '.html'
    if name == 'device': return f'{PYTORCH_DOCS}tensor_attributes{ext}#torch-device'
    if name == 'Tensor': return f'{PYTORCH_DOCS}tensors{ext}#torch-tensor'
    if name.startswith('torchvision'):
        doc_path = get_module_name(ft).replace('.', '/')
        if inspect.ismodule(ft): name = name.replace('.', '-')
        return f'{PYTORCH_DOCS}{doc_path}{ext}#{name}'
    if name.startswith('torch.nn') and inspect.ismodule(ft): # nn.functional is special case
        nn_link = name.replace('.', '-')
        return f'{PYTORCH_DOCS}nn{ext}#{nn_link}'
    paths = get_module_name(ft).split('.')
    if len(paths) == 1: return f'{PYTORCH_DOCS}{paths[0]}{ext}#{paths[0]}.{name}'

    offset = 1 if paths[1] == 'utils' else 0 # utils is a pytorch special case
    doc_path = paths[1+offset]
    if inspect.ismodule(ft): return f'{PYTORCH_DOCS}{doc_path}{ext}#module-{name}'
    fnlink = '.'.join(paths[:(2+offset)]+[name])
    return f'{PYTORCH_DOCS}{doc_path}{ext}#{fnlink}'
def get_pytorch_link ( ft ) -> str : name = ft . __name__ ext = '.html' if name == 'device' : return f'{PYTORCH_DOCS}tensor_attributes{ext}#torch-device' if name == 'Tensor' : return f'{PYTORCH_DOCS}tensors{ext}#torch-tensor' if name . startswith ( 'torchvision' ) : doc_path = get_module_name ( ft ) . replace ( '.' , '/' ) if inspect . ismodule ( ft ) : name = name . replace ( '.' , '-' ) return f'{PYTORCH_DOCS}{doc_path}{ext}#{name}' if name . startswith ( 'torch.nn' ) and inspect . ismodule ( ft ) : nn_link = name . replace ( '.' , '-' ) return f'{PYTORCH_DOCS}nn{ext}#{nn_link}' paths = get_module_name ( ft ) . split ( '.' ) if len ( paths ) == 1 : return f'{PYTORCH_DOCS}{paths[0]}{ext}#{paths[0]}.{name}' offset = 1 if paths [ 1 ] == 'utils' else 0 doc_path = paths [ 1 + offset ] if inspect . ismodule ( ft ) : return f'{PYTORCH_DOCS}{doc_path}{ext}#module-{name}' fnlink = '.' . join ( paths [ : ( 2 + offset ) ] + [ name ] ) return f'{PYTORCH_DOCS}{doc_path}{ext}#{fnlink}'
Returns link to pytorch docs of `ft`.