code: def get_x_per_row(
      self,
      xtype,
      mat,
      anchor_idx,
      other_idx,
      val_range=None,
      semihard_thresholds=None,
  ):
      assert xtype in ["min", "max"]
      inf = (
          c_f.pos_inf(mat.dtype)
          if xtype == "min"
          else c_f.neg_inf(mat.dtype)
      )
      mask = torch.ones_like(mat) * inf
      mask[anchor_idx, other_idx] = 1
      if semihard_thresholds is not None:
          if xtype == "min":
              condition = mat <= semihard_thresholds.unsqueeze(1)
          else:
              condition = mat >= semihard_thresholds.unsqueeze(1)
          mask[condition] = inf
      if val_range is not None:
          mask[(mat > val_range[1]) | (mat < val_range[0])] = inf
  
      non_inf_rows = torch.any(mask != inf, dim=1)
      mat = mat.clone()
      mat[mask == inf] = inf
      dist_fn = torch.min if xtype == "min" else torch.max
      return dist_fn(mat, dim=1), non_inf_rows
  
file_path: pytorch-metric-learning/src/pytorch_metric_learning/miners/batch_easy_hard_miner.py
imports: import torch
  from ..utils import common_functions
  from ..utils import loss_and_miner_utils
  from .base_miner import BaseMiner
label_desc: Use image node_id 8 for calling the BatchEasyHardMiner obj's underlying member method code with example usage: obj.get_x_per_row(xtype, mat, anchor_idx, other_idx, val_range, semihard_thresholds) and returns: dist_fn,  non_inf_rows