code: def scalar_to_support(
      scalar: torch.Tensor, support_range: Tuple[int, int]
  ) -> torch.Tensor:
      """Converts tensor of scalars into probability support vectors corresponding to the provided range.
  
      :param scalar: Tensor of scalars to be converted
      :param support_range: Tuple holding the lower and upper bound of the supported value range.
      :return: Tensor of support vectors.
      """
  
      if not torch.all(
          torch.gt(scalar, support_range[0])
      ) or not torch.all(torch.lt(scalar, support_range[1])):
          print(
              BColors.print_colored(
                  f"WARNING: scalar {scalar} is our of support range {support_range}!",
                  color=BColors.WARNING,
              )
          )
  
      # make sure scalar lives within supported range
      scalar = torch.clamp(scalar, support_range[0], support_range[1])
      floor = scalar.floor()
      prob = scalar - floor
  
      # initialize tensor of support vectors
      support_set_size = support_range[1] - support_range[0] + 1
      support = torch.zeros(
          list(scalar.shape) + [support_set_size], device=scalar.device
      )
  
      # write lower indices
      lower_indices = (floor - support_range[0]).long()
      indices = torch.clamp(lower_indices, 0, support_set_size - 1)
      support = support.scatter_add(
          dim=-1,
          index=indices.unsqueeze(-1),
          src=1.0 - prob.unsqueeze(-1),
      )
  
      # write upper indices
      upper_indices = lower_indices + 1
      indices = torch.clamp(upper_indices, 0, support_set_size - 1)
      support = support.scatter_add(
          dim=-1, index=indices.unsqueeze(-1), src=prob.unsqueeze(-1)
      )
  
      return support
  
file_path: maze/maze/train/trainers/common/value_transform.py
imports: from abc import ABC, abstractmethod
  from typing import Union, Tuple
  import numpy
  import torch
  from maze.core.annotations import override
  from maze.utils.bcolors import BColors
label_desc: Use image node_id 2 for calling a global function with example usage: scalar_to_support(scalar, support_range) and returns: support