code: def _construct_occ_number(
      a: float,
      floor_a: int,
      ceil_a: int,
      nlength: int,
      dtype: torch.dtype,
      device: torch.device,
  ) -> torch.Tensor:
      """Construct the occupation number (maxed at 1) where the total sum of the
      output equals to a with length of the output is nlength.
  
      Examples
      --------
      >>> import torch
      >>> _construct_occ_number(2.5, 2, 3, 3, torch.double, torch.device('cpu'))
      tensor([1.0000, 1.0000, 0.5000], dtype=torch.float64)
  
      Parameters
      ----------
      a: float
          Total sum of the output
      floor_a: int
          Floor of a
      ceil_a: int
          Ceiling of a
      nlength: int
          Length of the output
      dtype: torch.dtype
          Data type of the output
      device: torch.device
          Device of the output
  
      Returns
      -------
      torch.Tensor
          The constructed occupation number
  
      """
      res = torch.zeros(nlength, dtype=dtype, device=device)
      res[:floor_a] = 1
      if ceil_a > floor_a:
          res[ceil_a - 1] = a - floor_a
      return res
  
file_path: deepchem/deepchem/utils/safeops_utils.py
imports: import math
  import torch
  from typing import Union, Optional, Tuple
label_desc: Use image node_id 4 for calling a global function with example usage: _construct_occ_number(a, floor_a, ceil_a, nlength, dtype, device) and returns: res