class_docstr: ## Configurations
class_docstr_tok: ["#","#","Configurations"]
docstr: ### Sample images
docstr_tok: ["#","#","#","Sample","images"]
code: def sample(self, idx=-1):
      """
      ### Sample images
      """
  
      # Get a random sample
      x, _ = self.dataset[np.random.randint(len(self.dataset))]
      # Move data to device
      x = x.to(self.device)
  
      # Get predicted mask
      mask = self.sigmoid(self.model(x[None, :]))
      # Crop the image to the size of the mask
      x = torchvision.transforms.functional.center_crop(
          x, [mask.shape[2], mask.shape[3]]
      )
      # Log samples
      tracker.save("sample", x * mask)
  
file_path: annotated_deep_learning_paper_implementations/labml_nn/unet/experiment.py
imports: import numpy
  import torch
  import torch.utils.data
  import torchvision.transforms.functional
  from torch import nn
  from labml import lab, tracker, experiment, monit
  from labml.configs import BaseConfigs
  from labml_helpers.device import DeviceConfigs
  from labml_nn.unet.carvana import CarvanaDataset
  from labml_nn.unet import UNet
label_desc: Use image node_id 2 for calling the Configs obj's underlying member method code with example usage: obj.sample(idx) without return types