code: def _argmax_helper(
      enc_tensor,
      dim=None,
      one_hot=True,
      method="pairwise",
      _return_max=False,
  ):
      """
      Returns 1 for one randomly chosen element among all the elements that have
      the highest value in the appropriate dimension of the tensor. Sets up the CrypTensor
      appropriately, and then chooses among the different argmax algorithms.
      """
      if enc_tensor.dim() == 0:
          result = (
              enc_tensor.new(torch.ones(()))
              if one_hot
              else enc_tensor.new(torch.zeros(()))
          )
          if _return_max:
              return result, None
          return result
  
      updated_enc_tensor = (
          enc_tensor.flatten() if dim is None else enc_tensor
      )
  
      if method == "pairwise":
          result_args, result_val = _argmax_helper_pairwise(
              updated_enc_tensor, dim
          )
      elif method in [
          "log_reduction",
          "double_log_reduction",
          "accelerated_cascade",
      ]:
          result_args, result_val = _argmax_helper_all_tree_reductions(
              updated_enc_tensor, dim, method
          )
      else:
          raise RuntimeError("Unknown argmax method")
  
      # Break ties by using a uniform weighted sample among tied indices
      result_args = result_args.weighted_index(dim)
      result_args = (
          result_args.view(enc_tensor.size())
          if dim is None
          else result_args
      )
  
      if _return_max:
          return result_args, result_val
      else:
          return result_args
  
file_path: CrypTen/crypten/common/functions/maximum.py
imports: import math
  import crypten
  import torch
  from crypten.config import cfg
label_desc: Use image node_id 13 for calling a global function with example usage: _argmax_helper(enc_tensor, dim, one_hot, method, _return_max) and returns: result, result_args,  result_val, result_args, result,  None