code: def convert_to_raw(number, value, length):
          
  
          opt_type = defines.OptionRegistry.LIST[number].value_type
  
          if length == 0 and opt_type != defines.INTEGER:
              return bytes()
          elif length == 0 and opt_type == defines.INTEGER:
              return 0
          elif opt_type == defines.STRING:
              if isinstance(value, bytes):
                  return value.decode("utf-8")
          elif opt_type == defines.OPAQUE:
              if isinstance(value, bytes):
                  return value
              else:
                  return bytes(value, "utf-8")
          if isinstance(value, tuple):
              value = value[0]
          if isinstance(value, str):
              value = str(value)
          if isinstance(value, str):
              return bytearray(value, "utf-8")
          elif isinstance(value, int):
              return value
          else:
              return bytearray(value)
docs: Get the value of an option as a ByteArray.
  
          :param number: the option number
          :param value: the option value
          :param length: the option length
          :return: the value of an option as a BitArray