class_docstr: ## Sampler
  
  This samples a sketch from the decoder and plots it
class_docstr_tok: ["#","#","Sampler","This","samples","a","sketch","from","the","decoder","and","plots","it"]
code: def plot(seq: torch.Tensor):
      # Take the cumulative sums of $(\Delta x, \Delta y)$ to get $(x, y)$
      seq[:, 0:2] = torch.cumsum(seq[:, 0:2], dim=0)
      # Create a new numpy array of the form $(x, y, q_2)$
      seq[:, 2] = seq[:, 3]
      seq = seq[:, 0:3].detach().cpu().numpy()
  
      # Split the array at points where $q_2$ is $1$.
      # i.e. split the array of strokes at the points where the pen is lifted from the paper.
      # This gives a list of sequence of strokes.
      strokes = np.split(seq, np.where(seq[:, 2] > 0)[0] + 1)
      # Plot each sequence of strokes
      for s in strokes:
          plt.plot(s[:, 0], -s[:, 1])
      # Don't show axes
      plt.axis("off")
      # Show the plot
      plt.show()
  
imports: import math
  from typing import Optional, Tuple, Any
  import numpy
  import torch
  import torch.nn
  from matplotlib import pyplot
  from torch import optim
  from torch.utils.data import Dataset, DataLoader
  import einops
  from labml import lab, experiment, tracker, monit
  from labml_helpers.device import DeviceConfigs
  from labml_helpers.module import Module
  from labml_helpers.optimizer import OptimizerConfigs
  from labml_helpers.train_valid import TrainValidConfigs, hook_model_outputs, BatchIndex
label_desc: Use image node_id 4 for calling the Sampler obj's underlying member method code with example usage: obj.plot(seq) without return types