code: def negative_sampler(
      unique: bool, algorithm
  ) -> cs_config_pb2.NegativeSamplerConfig:
      """Builds a NegativeSamplerConfig from given input.
  
      Args:
        unique: a bool indicating if the samples should be unique.
        algorithm: the sampler algorithm defined by NegativeSamplerConfig.Sampler.
  
      Returns:
        A NegativeSamplerConfig proto.
      """
      if isinstance(algorithm, typing.Text):
          algorithm = cs_config_pb2.NegativeSamplerConfig.Sampler.Value(
              algorithm
          )
      if isinstance(algorithm, int):
          if algorithm not in [
              cs_config_pb2.NegativeSamplerConfig.UNIFORM,
              cs_config_pb2.NegativeSamplerConfig.LOG_UNIFORM,
          ]:
              raise ValueError("Invalid sampler type.")
      else:
          raise ValueError("Invalid input: %r" % algorithm)
  
      return cs_config_pb2.NegativeSamplerConfig(
          unique=unique, sampler=algorithm
      )
  
imports: import typing
  from research.carls.candidate_sampling import candidate_sampler_config_pb2
label_desc: Use image node_id 1 for calling a global function with example usage: negative_sampler(unique, algorithm) and returns: cs_config_pb2