<jupyter_start><jupyter_text>We create a Variable with Float tensorThe return value is not a variable instead it is a tensor<jupyter_code>var = Variable(torch.FloatTensor([9]))
var # returns a tensor anyway
var.requires_grad
var.requires_grad_()# used to enable Variable api functions<jupyter_output><empty_output><jupyter_text>We create two weight variables with gradients enabled<jupyter_code>w1 = Variable(torch.FloatTensor([3]), requires_grad = True)
w2 = Variable(torch.FloatTensor([7]), requires_grad = True)
w1
w2<jupyter_output><empty_output><jupyter_text>We create two more variables using the weights<jupyter_code>result_var = var * w1

result_var<jupyter_output><empty_output><jupyter_text>New variables derive enabled gradients from weights<jupyter_code>result_var.requires_grad
#calculate gradients for all of the input tensors
result_var.backward()
w1.grad
w2.grad
var.grad<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.08505997818974918, 'fraction_numerical': 0.010905125408942203, 'mean_word_length': 8.663157894736843, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '101368', 'license': 'MIT', 'n_tokens_mistral': 306, 'n_tokens_neox': 296, 'n_words': 76, 'path': 'pyTorch_PS/PT06-AutogradWithVariables.ipynb', 'repo_name': 'rsunderscore/learning', 'size': '917'}