parameters: (per_example_loss)
docstring: Context manager that checks that the rank of per_example_loss is atleast 1.
  
    Args:
      per_example_loss: Per example loss tensor.
  
    Yields:
      A context manager.
docstring_summary: Context manager that checks that the rank of per_example_loss is atleast 1.
docstring_tokens: Context manager that checks that the rank of per_example_loss is atleast 1 .
function: def check_per_example_loss_rank(per_example_loss):
    """Context manager that checks that the rank of per_example_loss is atleast 1.
  
    Args:
      per_example_loss: Per example loss tensor.
  
    Yields:
      A context manager.
    """
    loss_rank = per_example_loss.shape.rank
    if loss_rank is not None:
      # Handle static rank.
      if loss_rank == 0:
        raise ValueError(
            "Invalid value passed for `per_example_loss`. Expected a tensor with "
            "at least rank 1, received: {}".format(per_example_loss))
      yield
    else:
      # Handle dynamic rank.
      with ops.control_dependencies([
          check_ops.assert_greater_equal(
              array_ops.rank(per_example_loss),
              math_ops.cast(1, dtype=dtypes.int32),
              message="Invalid value passed for `per_example_loss`. Expected a "
              "tensor with at least rank 1.")
      ]):
        yield
function_tokens: def check_per_example_loss_rank ( per_example_loss ) : loss_rank = per_example_loss . shape . rank if loss_rank is not None : # Handle static rank. if loss_rank == 0 : raise ValueError ( "Invalid value passed for `per_example_loss`. Expected a tensor with " "at least rank 1, received: {}" . format ( per_example_loss ) ) yield else : # Handle dynamic rank. with ops . control_dependencies ( [ check_ops . assert_greater_equal ( array_ops . rank ( per_example_loss ) , math_ops . cast ( 1 , dtype = dtypes . int32 ) , message = "Invalid value passed for `per_example_loss`. Expected a " "tensor with at least rank 1." ) ] ) : yield